;+ ; NAME month_day.pro ; ; PURPOSE Compute month & day corresponding to a Day-Of-Year. ; ; AUTHOR Alice Lecinski HAO/NCAR mon_day.c ; ; HISTORY Andrew L. Stanger HAO/NCAR 19 Nov 2002 ; 19 Nov 2002: Convert from C to IDL. ; ;- PRO month_day, idoy, iyear, month, day day_tab = INTARR (13, 2) day_tab [*, 0] = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] day_tab [*, 1] = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] year = iyear doy = idoy leap = LONG ((year MOD 4 EQ 0) AND (year MOD 100 NE 0) OR $ (year MOD 400 EQ 0)) ; leap = (y4 EQ 0) AND (y100 NE 0) OR (y400 EQ 0) ii = 1 WHILE (doy GT day_tab [ii, leap]) DO $ BEGIN ; IF (ii > 12) THEN PRINT, 'idoy, iyear, ii, doy: ', idoy, iyear, ii, doy PRINT, 'idoy, iyear, ii, doy: ', idoy, iyear, ii, doy doy = doy - day_tab [ii, leap] ii = ii + 1 END month = ii ; day = doy ; END