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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Time convertion [message #24125] Wed, 14 March 2001 10:57 Go to next message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
I have two observations about this posting, both bothered me.

JD Smith wrote:

> st=(julday(month,day,year,hr,min,sec)-2440587.5D)*86400.0D

I am not able to see HISTOGRAM in here. My news reader must require an
update, since some ASCII characters got lost in transfer.

> Keeping in mind that systime(1) often returns GMT on many systems

*Often* and *Many systems* !? Isn't it something you are supposed to be
able to count on? Or, you mean those systems that have a clock screwed up?

Cheers,
Pavel
Re: Time convertion [message #24126 is a reply to message #24125] Wed, 14 March 2001 10:50 Go to previous messageGo to next 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
Re: Time convertion [message #24127 is a reply to message #24126] Wed, 14 March 2001 10:17 Go to previous messageGo to next message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Alex Schuster wrote:
> 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 :)

http://fermi.jhuapl.edu/s1r/idl/s1rlib/time/time.html

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley
Re: Time convertion [message #24128 is a reply to message #24127] Wed, 14 March 2001 09:44 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Pavel A. Romashkin (pavel.romashkin@noaa.gov) writes:

> Alex Schuster wrote:
>>
>> Some big routine
>> with many, many keywords to convert between all those formats would be
>> nice :)
>
> You mean, some *small*, perfectly working routine, preferably written by DF?...

Uh, huh. And you are offering to pay how much!?

Cheers,

David

P.S. Let's just say that if something like this doesn't
exist at either the JHUAPL library or at the NASA library,
something is *seriously* wrong with the world. :-(

By the way, I offer a 50% discount on my fees if I can
steal the program from somewhere else. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Time convertion [message #24130 is a reply to message #24128] Wed, 14 March 2001 09:09 Go to previous messageGo to next message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Alex Schuster wrote:
>
> Some big routine
> with many, many keywords to convert between all those formats would be
> nice :)

You mean, some *small*, perfectly working routine, preferably written by DF?...

Pavel
Re: Time convertion [message #24222 is a reply to message #24126] Wed, 14 March 2001 11:52 Go to previous messageGo to next message
tam is currently offline  tam
Messages: 48
Registered: February 2000
Member
JD Smith wrote:
... 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
>
...
>
> JD

How are leap seconds accounted for here? They usually cause
niggling problems if one actually needs to worry about
precision at the second level over periods of more than a
month or two. It looks like your code is ignoring them.
The biggest pain is that they are not predictable so the
code needs to access an external file, or update an
internal table periodically.

Regards,
Tom McGlynn
Re: Time convertion [message #24224 is a reply to message #24126] Wed, 14 March 2001 11:30 Go to previous messageGo to next message
Wayne Landsman is currently offline  Wayne Landsman
Messages: 117
Registered: January 1997
Senior Member
>
> 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).

SYSTIME() was upgraded in V5.4 so that systime(1) is supposed to return GMT
on all systems. (I believe that it used to return GMT on Windows and Unix,
but local time on VMS and MacOS.)
SYSTIME(0) always returns local time (as in earlier IDL versions), but now
one can also return GMT using the new /UTC keyword. Also, note that one
can now directly return the Julian date with the /Julian keyword.

(Universal Coordinated Time (UTC) was formerly known as Greenwich Mean Time
(GMT). )

--Wayne
Landsman
landsman@mpb.gsfc.nasa.gov
Re: Time convertion [message #24247 is a reply to message #24130] Tue, 20 March 2001 06:03 Go to previous messageGo to next message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
"Pavel A. Romashkin" wrote:

> Alex Schuster wrote:
>
>> Some big routine
>> with many, many keywords to convert between all those formats
>> would be nice :)
>
> You mean, some *small*, perfectly working routine, preferably
> written by DF?...

No, I'd prefer it to be big, very big. So I can watch it being compiled
and I can think, wow, this take sa long time, there must be some many
really cool great amazing routines in it! And it should accept all
formats, be it one of the various string formats, or secs-since-1970, or
Julian Days, Chinese years, nanoseconds-since-big-bang or whatever.

Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
Re: Time convertion [message #24248 is a reply to message #24126] Tue, 20 March 2001 06:04 Go to previous message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
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
Re: Time convertion [message #24256 is a reply to message #24127] Mon, 19 March 2001 13:12 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
"Liam E. Gumley" wrote:
>
> Alex Schuster wrote:
>> 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 :)
>
> http://fermi.jhuapl.edu/s1r/idl/s1rlib/time/time.html

and here are some more julian seconds routines


http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/string2js.tar.gz
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/js2string.tar.gz


There are many formats defined

e.g.:
; FORMAT: string to format the output:
; 'ICG' = 'Y-M-D H:M:S MS'
; 'XLS' = 'D.M.Y H:M:S'
; 'M-D'
; 'H:M'
; 'H:M:S'
; 'Y-M-D'
; 'M-D-Y'
; 'YMDHMS'


For further routines and licensing please look at
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml




regards

Reimar

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum J�lich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
  Switch to threaded view of this topic Create a new topic Submit Reply
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:37:30 PDT 2025

Total time taken to generate the page: 0.00816 seconds