comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Time convertion
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Time convertion [message #24126 is a reply to message #24125] Wed, 14 March 2001 10:50 Go to previous messageGo to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
Alex Schuster wrote:
>
> Hi!
>
> I have to convert some date formats, and I wonder why IDL does not give
> more support here. A common date/time format is the seconds since 1970,
> and the systime() funtion can return the current date in this format.
> Yippie! But why is there no function to convert this from/to standard
> ASCII date strings, or from/to Julian date?
>
> 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. The recent
IDL-bundled "caldat" will work just as well for that now. 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

That's it! For instance:

IDL> st0=systime(0) & st1=systime(1)
IDL> d=bin_date(st0)
IDL> st=(julday(d[1],d[2],d[0],d[3],d[4],d[5])-2440587.5D)*86400. 0D
IDL> print,FORMAT='(A,":",2D30.5)',st0,st1,st

Keeping in mind that systime(1) often returns GMT on many systems,
whereas systime(0) returns localtime, meaning you might have several
hours offset between st1 and st above. For me, st1-st=5 hours (EST).

Good luck,

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: AD&D site / sito AD&D
Next Topic: Time convertion

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:55:58 PDT 2025

Total time taken to generate the page: 0.00215 seconds