Re: Julian Dates...Again [message #53761] |
Tue, 01 May 2007 11:35 |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Tue, 01 May 2007 10:31:00 -0700, David Fanning wrote:
> Folks,
>
> OK, I don't have time for this today... :-(
>
> Suppose I have a time string: "2007118".
> The first four digits are the year. The last
> three digits are the day of the year. (e.g.,
> Jan 10, 2007 is 010 and Feb 1, 2007 is 032, etc.)
>
> I can't seem to put my hands on a function that will
> convert the day of the year to a month and day value,
> so that I can create a Julian number with JULDAY.
> (Although I can imagine I have written such a thing in
> the past. All I have to do is find that damn formula
> for leap year processing and...)
>
> Does anyone have one of these do-hickeys available?
If you worry that Kuyper's trick goes against the documented input
requirements and so could be broken by future updates, just ask for
the Julian date of Jan 1st, then add 117 days:
IDL> print,julday(1,1,2007)+(118-1)
This doesn't validate your input time string (e.g. 2004366 is valid,
2000366 is not), but it will get the correct answer either way.
JD
|
|
|
Re: Julian Dates...Again [message #53762 is a reply to message #53761] |
Tue, 01 May 2007 11:14  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
kuyper@wizard.net writes:
> Well, you could do the following:
>
> CALDATE,JULDAY(1, 118, 2007), month, day
>
> But I presume the JULDAY call itself will do what you really need. :-)
> This technique of using January 118th to find the 118th day of the
> year seems to work with a lot of different date-handling functions on
> a wide variety of platforms.
Seriously!? Of course, you have to mis-spell CALDATE as
CALDAT to get it to work, but that is wonderful! :-)
I found the JHUAPL files. I wasn't relaxed enough this
morning, despite my new afternoon routine of yoga and
Tai Chi, to search my distribution into the "Y"s. :-(
Thanks for your help.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Julian Dates...Again [message #53763 is a reply to message #53762] |
Tue, 01 May 2007 11:04  |
news.verizon.net
Messages: 47 Registered: August 2003
|
Member |
|
|
On May 1, 1:31 pm, David Fanning <n...@dfanning.com> wrote:
> I can't seem to put my hands on a function that will
> convert the day of the year to a month and day value,
> so that I can create a Julian number with JULDAY.
>
I am always using Ray Sterner's little procedures at
ftp://nansen.jhuapl.edu/pub/idl/routines for this
ydn2md Convert from year and day number of year to month and day of
month.
ymd2dn() Convert from year, month, day to day number of year.
--Wayne
|
|
|
Re: Julian Dates...Again [message #53764 is a reply to message #53763] |
Tue, 01 May 2007 10:52  |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
David Fanning wrote:
> Folks,
>
> OK, I don't have time for this today... :-(
>
> Suppose I have a time string: "2007118".
> The first four digits are the year. The last
> three digits are the day of the year. (e.g.,
> Jan 10, 2007 is 010 and Feb 1, 2007 is 032, etc.)
>
> I can't seem to put my hands on a function that will
> convert the day of the year to a month and day value,
> so that I can create a Julian number with JULDAY.
> (Although I can imagine I have written such a thing in
> the past. All I have to do is find that damn formula
> for leap year processing and...)
Well, you could do the following:
CALDATE,JULDAY(1, 118, 2007), month, day
But I presume the JULDAY call itself will do what you really need. :-)
This technique of using January 118th to find the 118th day of the
year seems to work with a lot of different date-handling functions on
a wide variety of platforms.
|
|
|