Organization: Jet Propulsion Laboratory, Pasadena, CA
Subject: Re: Seeking a days-between-dates algorithm...
>I saw in either K&P or Stephen Kochan's C book an algorithm to
>convert month, day and year to Julian.
[C code deleted]
I saw that algorithm too, and like you I didn't understand it. (Here's
one thing that C and RPL have in common!)
The best algorithm I've found so far for calculating the Julian
day number looks like this:
JDN = int(int(int(367*y') - int(y') - .75 * int(y') + D)
- .75 * int(y'/100)) + 1,721,115
where
y' = Y + (M - 2.85) / 12
This formula is based on an idealized year of 367 days, and
shortening it by the appropriate amount in the other terms. The last
term represents the day number of March 1, 0 A.D., and can safely be
omitted when calculating differences in days.
While researching this I finally understood that Pope Gregory had
actually introduced a drift correction over the existing
leap-year-every-four-years rule introduced under Juleas Caesar (hence
the name Julian, also the name July. August was named for Augustus
(let me know if I'm spelling any of these right.)) What I don't understand
is how these corrections could be calculated when the Church still insisted
that the earth was the center of the universe. Were star positions
consulted in calculating the earth's position? Could they have done their
impersonation of the Kremlin:?
"There was no nuclear accident."
(Pssst, Vlad, how's the nuclear clean-up coming?)
"I say with great authority that the Sun revolves around the
earth!"
(Pssst, Luigi! Ignore that or else our wrong calculations
will make us look bad!)
(I suppose with the current political climate Libya and its poison gas
plant would be a more appropriate analogy than the Soviet Union.) (Anyway,
I was in Latvia two years ago so I can make these jokes.)
500 years elapsed between when the correction was proposed and
when the last country adopted it in 1927 (Turkey). The American
colonies adopted it around 1750.
There is also a proposed modification to the calender, which would
make all years divisible by 4000 a non-leap year to correct the drift
even further. History teaches us that it won't be adapted for another
450 years, though.
>
>Tried to send mail to gary, but...
>
'Preciate it, Tom.
I'd like to thank all the people who took the time to respond. The
Internet sure is a wonderful fountain of knowledge!!
-Garyf
--
Gary Friedman Jet Propulsion Laboratory - NASA
4800 Oak Grove Drive, Pasadena, CA. 91109 (818) 354-0410
Uucp: {cit-vax,elroy,psivax}!devvax!garyf
Arpa: devvax!garyf@cit-vax.ARPA -or- garyf@devvax.JPL.NASA.GOV