Re: HELP with systime() [message #10881 is a reply to message #10877] |
Wed, 11 February 1998 00:00   |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
Mark Elliott <mark@mail.mmrrcc.upenn.edu> writes:
> Is there a way to convert a binary time value like the one
> returned by
> timeval = systime(1)
> into a date string like
> DOW MON DD HH:MM:SS YEAR ?
> I've found bin_date() but it accepts only the ascii_time format
> for input. I'd like to convert the number of seconds since 1/1/1970 into
> the month,day,year,... that it corresponds to.
There are a number of time conversion routines available from
ftp://sohoftp.nascom.nasa.gov/solarsoft/gen/idl/time/
For example, the routine sec2utc can convert a time in seconds (ignoring leap
seconds) to calculate the Modified Julian Day (MJD) number, and the number of
milliseconds into the day. For example,
sec = systime(1)+40587.d0*86400.d0
utc = sec2utc(sec)
(40587 is the MJD of 1-Jan-1970, and 86400 is the number of seconds in a day.)
The routine anytim2utc can then be used to convert this into a number of
different formats. For example,
IDL> print,utc
{ 50855 82039210}
IDL> print, anytim2utc(utc,/ccsds)
1998-02-11T22:47:19.210Z
IDL> print, anytim2utc(utc,/vms)
11-Feb-1998 22:47:19.210
IDL> help, /structure, anytim2utc(utc,/ext)
** Structure CDS_EXT_TIME, 7 tags, length=14:
YEAR INT 1998
MONTH INT 2
DAY INT 11
HOUR INT 22
MINUTE INT 47
SECOND INT 19
MILLISECOND INT 210
The routine utc2dow calculates the day-of-week. For example,
IDL> dow = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
IDL> print, dow(utc2dow(utc))
Wed
There are also facilities for converting UTC time into TAI time, and
vice-versa, with leap-seconds fully accounted for.
Bill Thompson
|
|
|