; Subprogram: INVTIME ; Author: Mylene J. Remigio ; Date: November 13, 1997 ; Revision: For Y2K ; Author: Shyam Lakshmin ; Date; June 30, 1999 ; This procedure converts the minute timestamp for WOCE-MET ship ; data back into a standard year/month/day/hour/minute time. ; Based on the subroutine invtime.f ; INPUT VALUE: ; timestamp integer Number (in minutes) which repersents the ; time after January 1, 1980, at 00:00 ; UTC. Range is [0,21565440] ; OUTPUT VALUES: ; yr integer Year from timestamp. Range is ; [1980, 2020] If the year is greater ; than 2020, year is set to -9999 and 0 ; is the value of mon, day, hr, and min. ; mon integer The month from timestamp. Range is ; [1,12] ; day integer The day from timestamp. Range is ; [1,31], depending on the month ; hr integer The hour from timestamp. Range is ; [0,23] ; min integer The minute from timestamp. Range is ; [0,59] ;***********************************************************************/ pro invtime, timestamp, yr, mon, day, hr, min ; INITIALIZE VALUES year = LONARR(42) month = LONARR(13) leap_mon = LONARR(13) year = [0, 527040, 1052640, 1578240, 2103840, 2630880, $ 3156480, 3682080, 4207680, 4734720, 5260320, 5785920, 6311520, $ 6838560, 7364160, 7889760, 8415360, 8942400, 9468000, 9993600, $ 10519200, 11046240, 11571840, 12097440, 12623040, 13150080, $ 13675680, 14201280, 14726880, 15253920, 15779520, 16305120, $ 16830720, 17357760, 17883360, 18408960, 18934560, 19461600, $ 19987200, 20512800, 21038400, 21565440] month = [0, 44640, 84960, 129600, 172800, 217440, 260640, $ 305280, 349920, 393120, 437760, 480960, 525600] leap_mon = [0, 44640, 86400, 131040, 174240, 218880, 262080, $ 306720, 351360, 394560, 439200, 482400, 527040] min_day = 1440L min_hr = 60L ; YEAR CALCULATION if (timestamp GE year(41)) then begin yr = -9999 mon = 0 day = 0 hr = 0 min = 0 return endif iyr = 1979 itime = timestamp ttime = 0L i=0L while (ttime GE 0) do begin iyr = iyr + 1 ttime = itime - year(i + 1) if (ttime LT 0) then $ itime = itime - year(i) i = i + 1 endwhile yr = iyr ; MONTH CALCULATION imon = 0 mon = 0 i = 0 ttime = 0 ; IF YEAR IS A LEAP YEAR, DO WHILE LOOP if ( (iyr EQ 1980) OR (iyr EQ 1984) OR (iyr EQ 1988) OR (iyr EQ 1992) $ OR (iyr EQ 1996) OR (iyr EQ 2000) OR (iyr EQ 2004) OR (iyr EQ 2008) $ OR (iyr EQ 2012) OR (iyr EQ 2016) OR (iyr EQ 2020) ) then begin while (ttime GE 0) do begin imon = imon + 1 ttime = itime - leap_mon(i + 1) if (ttime LT 0) then $ itime = itime - leap_mon(i) i = i + 1 endwhile ; ELSE, DO THIS WHILE LOOP endif else begin while (ttime GE 0) do begin imon = imon + 1 ttime = itime -month(i+1) if (ttime LT 0) then $ itime = itime - month(i) i = i + 1 endwhile endelse mon = imon ; DAY CALCULATION iday = 0 i = 0 ttime = 0 while (ttime GE 0) do begin iday = iday + 1 ttime = itime - ( min_day * (i + 1) ) if (ttime LT 0) then $ itime = itime - ( min_day * i ) i = i + 1 endwhile day = iday ; HOUR CALCULATION ihour = -1 i = 0 ttime = 0 while (ttime GE 0) do begin ihour = ihour + 1 ttime = itime - ( min_hr * (i + 1) ) if (ttime LT 0) then $ itime = itime - ( min_hr * i ) i = i + 1 endwhile hr = ihour ; WHATEVER IS LEFT OF INVTIME IS THE MINUTE CALCULATION min = itime end