[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Time convertion
Alex Schuster wrote:
>
> JD Smith wrote:
>
> > Alex Schuster wrote:
>
> > > I found such a thing in the Astro library, st2date, input is the
> > > seconds-since-1970, output is year, month, day etc., and even day and
> > > month in ASCII notation if one likes. Great. But I did not find
> > > something yet to convert to seconds-since-1970. I could write it myself,
> > > but I guess this already had be done some dozen times. Some big routine
> > > with many, many keywords to convert between all those formats would be
> > > nice :)
> >
> > Hmm... I doubt you found that in the Astro library, since I wrote it and
> > posted it to the newsgroup back in 1998. I did use daycnv from the
> > astro package to convert julian to calendar dates.
>
> Umm, right. I found it in the folder where my copy of the Astro library
> resides.
>
> > The recent
> > IDL-bundled "caldat" will work just as well for that now.
>
> Hooray! I hope it also can output various time strings... but I'm still
> using IDL 5.2 :(
>
> > In any case,
> > it is oh so trivial to convert date to systime, the inverse:
> >
> > st=(julday(month,day,year,hr,min,sec)-2440587.5D)*86400.0D
>
> Okay, right. Once you know that these Julian Days are, and if you don't
> think about leap seconds. I already did the same, but made the mistake
> of using julday(1,1,1970) instead of julday(1,1,1970,0,0,0), which gives
> half a day offset. Okay, my fault, but if IDL already had such a
> conversion routine, I wouldn't have to think about it, and I wouldn't be
> able to make such mistakes.
> Another example, why can't systime() just also output julian days, give
> it one more keyword and that's it.
You mean like:
============================================================================
Keywords
JULIAN
Set this keyword to specify that the current time is to be returned as a
a double precision floating value containing the current Julian
date/time....
============================================================================
Looks like you are in need of an upgrade. By the way, julian time
explicitly includes no leap seconds, meaning you don't have to think
about them. In this sense, it is not tied to any physical period (just
as seconds since Jan 1, 1970 is not) -- it's simply a continuous time
base for ease of intercomparison.
See:
http://hpiers.obspm.fr/webiers/general/syframes/convent/UAI_b1.html
(credit to Tom McGlynn for the link)
JD