; Copyright 2020 Florida State University, Center for Ocean-Atmospheric Prediction Studies ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal ; in the Software without restriction, including without limitation the rights ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ; copies of the Software, and to permit persons to whom the Software is ; furnished to do so, subject to the following conditions: ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ; SOFTWARE. FUNCTION __is_leap_year, year IF ((year MOD 400) EQ 0) THEN RETURN, 1 ELSE $ IF ((year MOD 100) EQ 0) THEN RETURN, 0 ELSE $ IF ((year MOD 4) EQ 0) THEN RETURN, 1 ELSE $ RETURN, 0 END FUNCTION __minutes_in_year, year IF __is_leap_year(year) THEN RETURN, LONG(527040) ELSE RETURN, LONG(525600) END FUNCTION __minutes_in_month, month, year minutes_per_month = LONARR(12) minutes_per_month(*) = [44640,40320,44640,43200,44640,43200,44640,44640,$ 43200,44640,43200,44640] IF (__is_leap_year(year)) THEN BEGIN minutes_per_month[1] = minutes_per_month[1] + LONG(1440) ENDIF RETURN, minutes_per_month[month-1] END ; NAME: ; CONVTIME ; ; AUTHOR: ; Jiraporn Whalley (whalley@coaps.fsu.edu) ; ; REVISION for Y2K: ; AUTHOR: ; Shyam Lakshmin (lakshmin@cs.fsu.edu) ; DATE: ; July 8, 1999 ; ; REVISION for Y2020: ; AUTHOR: ; Homer McMillan (hmcmillan@coaps.fsu.edu) ; DATE: ; February 11, 2020 ; ; PURPOSE: ; This function returns time in minutes from 1-1-1980 00:00. ; ; CALLING SEQUENCE: ; RESULT = CONVTIME(YR, MO, DY, HR, MN) ; ; INPUTS: ; YR (Integer) Year in the range [1980, 2020]. ; MO (Integer) 2 digits abbreviation of month, [1, 12]. ; DY (Integer) Day of month, [1, 31]. ; HR (Integer) Hour of the day, [0, 23]. ; MN (Integer) Minute of the hour, [0, 59]. ; ; OUTPUTS: ; RESULT: (Long) Minutes from 1-1-1980 00:00. ; ; KEYWORD PARAMETERS: ; ; RESTRICTIONS: ;- ;============================================================================= FUNCTION CONVTIME, year, month, day, hour, minute temp_year = LONG(year - 1) timestamp = LONG(0) ; compute the minute contributions from the number of *full* years between ; 1980-01-01 00:00:00 and the given date WHILE (temp_year GT 1979) DO BEGIN timestamp += __minutes_in_year(temp_year) temp_year -= 1 ENDWHILE ; compute the minute contributions from the number of *full* months between ; 1980-01-01 00:00:00 and the given date month -= 1 WHILE (month GT 0) DO BEGIN timestamp += __minutes_in_month(month, year) month -= 1 ENDWHILE ; convert days to minutes day -= 1 WHILE (day GT 0) DO BEGIN timestamp += 1440 day -= 1 ENDWHILE ; convert hours to minutes WHILE (hour GT 0) DO BEGIN timestamp += 60 hour -= 1 ENDWHILE timestamp += minute RETURN, timestamp END ; Subprogram: INVTIME ; Author: Mylene J. Remigio ; Date: November 13, 1997 ; Revision: For Y2K ; Author: Shyam Lakshmin ; Date: June 30, 1999 ; Revision: For Y2020 ; Author: Homer McMillan ; Date: February 11, 2020 ; 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 ; 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] [0,59] PRO INVTIME, timestamp, year, month, day, hour, minute local_timestamp = timestamp year = LONG(1980) month = LONG(1) day = LONG(1) hour = LONG(0) minute = LONG(0) temp_timestamp = __minutes_in_year(year) ; convert minutes to years WHILE (local_timestamp GE temp_timestamp) DO BEGIN year += 1 local_timestamp -= temp_timestamp temp_timestamp = __minutes_in_year(year) ENDWHILE ; convert minutes to months temp_timestamp = __minutes_in_month(month, year) WHILE (local_timestamp GE temp_timestamp) DO BEGIN month += 1 local_timestamp -= temp_timestamp temp_timestamp = __minutes_in_month(month, year) ENDWHILE ; convert minutes to days WHILE (local_timestamp GE 1440) DO BEGIN day += 1 local_timestamp -= 1440 ENDWHILE ; convert minutes to hours WHILE (local_timestamp GE 60) DO BEGIN hour += 1 local_timestamp -= 60 ENDWHILE minute = local_timestamp END