[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Time convertion



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. 

Reimar's link was a good tip and made things easier:
http://fermi.jhuapl.edu/s1r/idl/s1rlib/time/time.html
Many many routines converting various time and/or date strings to other
formats (of course no direct conversion to secs-since-1970).

-- 
  Alex Schuster     Wonko@weird.cologne.de          PGP Key available
                    alex@pet.mpin-koeln.mpg.de