;+____________________________________________________________________________ ;_ ;_ Date-time routines from PRASSADCO ;-____________________________________________________________________________ PRO CALTIME, Julian, Msec, Sec, Mn, Hour, Day, Month, Year, roundsec=roundsec ;+ ; NAME: ; CALTIME ; ; PURPOSE: ; Return the time, day, month and year corresponding to a given modified julian time. ; This is the inverse of the function JULTIME. ; Vector version now. Modified Julian offset updated. ; CATEGORY: ; Misc. ; ; CALLING SEQUENCE: ; CALTIME, Julian, Msec, Sec, Min, Hour, Day, Month, Year ; See also: jultime, the inverse of this function. ; ; INPUTS: ; JULIAN contains the Modified Julian Time of the ; specified calendar date and time. It should be a double float-point scalar or vector. ; OUTPUTS: ; MSEC: Number of miliseconds. ; ; SEC: Number of seconds. ; ; MIN: Number of minutes. ; ; HOUR: Number of hours. ; ; DAY: Number of day of the month. ; ; MONTH: Number of the desired month (1 = January, ..., 12 = December). ; ; YEAR: Number of the desired year. ; Scalar/vector type of output parameters is inherited from input. ; ; MODIFICATION HISTORY: ; ; v1.3 - extension to vectors, by LP, Aug, 1994 ; v1.4 - MOFF updated, by LP, May, 1995 ; v1.5 - 1000ms bug removed, roundsec keyword, OS, III/1997 ; v1.6 - time construction from ms - to prevent roundoff errors (60s) , OS, VII/1997 ; v1.7 - roundoff bug fixed: MOFF is now long (not double) o.s. iv/1998 ;- ; ON_ERROR, 2 ; Return to caller if errors MOFF = 2400001L ; drive 2400000 ;__get time_of_day temp = round((Julian - long(Julian)) * 8.64d7) i24h=where(temp eq 86400000L,n24h) if n24h ne 0 then temp(i24h)=0L temp=double(temp) if keyword_set(roundsec) then temp = round(temp/1000d0)*1000d0 msec=round(temp mod 1d3) sec=long(temp/1d3 mod 60d0) mn=long(temp/6d4 mod 60d0) hour=long(temp/3.6d6) ;__separate date and time_of_day JulianDay=round(Julian-(hour+(mn+(sec+1d-3*msec)/60d0)/60d0)/24d0)+MOFF ;__converse date (caldat) IGREG = 2299161L ;Beginning of Gregorian calendar ;Inherit scalar/vector type of input parameter jb = julianday JULD = julianday ii1 = where(julianday ge igreg, count) if count ne 0 then begin JULD(ii1) = long(((julianday(ii1) - 1867216) - 0.25d0) / 36524.25) jb(ii1) = julianday(ii1) + 1 + JULD(ii1) - long(0.25d0 * JULD(ii1)) endif ; date conversion jb = temporary(jb) + 1524 year = long(6680.0 + ((jb-2439870)-122.1)/365.25) JULD = long(365 * year + (0.25 * year)) month = long((jb - JULD) / 30.6001) day = jb - JULD - long(30.6001 * month) month = temporary(month) - 1 ii1 = where(month gt 12, count) if count ne 0 then month(ii1) = month(ii1) - 12 year = temporary(year) - 4715 ii1 = where(month gt 2, count) if count ne 0 then year(ii1) = year(ii1) - 1 ii1 = where(year le 0, count) if count ne 0 then year(ii1) = year(ii1) - 1 END