Lazzar wrote:
>
> Is anyone aware of a means of converting ANSI C standard time (the
> number of seconds since 00:00:00 1/1/70) to a real time and date in IDL?
>
> Thanks,
>
> Brian
I coded something up for this which uses the daycnv nasa astro routine.
It's attached.
Good Luck,
JD
--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
;+
; NAME: st2date
;
; PURPOSE: Convert systime(1) type elapsed seconds to calendar dates.
;
; CALLING SEQUENCE: st2date, st, yr,mn,day,hr,min,sec,WDAY=wday,MON=mon,
; FORM=form
;
; INPUTS:
; st: The double number of seconds since Jan 1,1970 (as returned
; by systime(1)).
;
; OPTIONAL OUTPUTS: (all outputs optional)
; yr: The year
; mn: The month
; day: The day of the month
; hr: The hour of the day
; min: The minute
; sec: The second, including fractional part.
; KEYWORDS:
; WDAY=wday: The day of the week, abbreviated as a string of length 3
; MON=mon: The month, abbreviated as a string of length 3
; FORM=form: The entire date formatted as in systime(0)
;
; MODIFICATION HISTORY:
; 9/19/98: Written, JDS
;
; PROCEDURES: DAYCNV (from the NASA Astro package.)
;
; NOTES: The date returned by systime(1) may or may not be in UT,
; depending on the operating system.
;-
pro st2date, st,yr,mn,day,hr,min,sec,WDAY=wday,MON=mon,FORM=form
on_error,2
if size(st,/TYPE) ne 5 then begin
message,'Input systime must be of type double.'
return
endif
days=st/86400.0D ;convert seconds to days.
jd=days+2440587.5D ;add julian date of Jan. 1,1970, 0.0h
daycnv, jd, yr, mn, day, hr
min=(hr-floor(hr))*60.0D
sec=(min-floor(min))*60.0D
hr=floor(hr)
min=floor(min)
;; find the calendar day -- midnight-midnight, not noon-noon (add .5)
wday=(['Sun','Mon','Tue','Wed','Thu','Fri','Sat'])[floor((jd +1.5) mod 7)]
mon=(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', 'Oct','Nov', $
'Dec'])[mn-1]
if arg_present(form) then $
form=string(FORMAT='(A3," ",A3," ",I2," ",2(I2.2,":"),I2.2," ",I4)', $
wday,mon,day,hr,min,floor(sec),yr)
end
-
Attachment: st2date.pro
(Size: 1.73KB, Downloaded 68 times)
|