Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!mejac!orchard.la.locus.com!fafnir.la.locus.com!fafnir.la.locus.com!richard From: richard@locus.com (Richard M. Mathews) Newsgroups: news.software.b Subject: Re: CNews - now a pedantic software! : -( Message-ID: Date: 16 Apr 91 07:01:06 GMT References: <3313@crdos1.crd.ge.COM> <5077@gazette.bcm.tmc.edu> <1991Apr09.160444.25262@looking.on.ca> <1991Apr9.185748.11721@mp.cs.niu.edu> <1991Apr9.221012.19572@visix.com> <9104122026.57@rmkhome.UUCP> <1991Apr13.233035.8779@looking.on.ca> Organization: Locus Computing Corporation, Los Angeles, California Lines: 99 brad@looking.on.ca (Brad Templeton) writes: >However, perhaps a floating point number of days is the most logical date >interchange format. This is clean, although FP minutes has the advantage >that people who want to just use integer math and don't care about seconds >have an easy out. Just about all news software would be fine with long integer >minutes, and those who really want accurate time could use the fractional part >if they desired. I am not taking a position for or against such a proposal. I would like to point out, however, that such a standard already exists. Astronomers and others have long had a need for dates with which calculations are easy. They use fractional days to whatever precision is appropriate, and they use a standard epoch. If you want to pick an epoch, why not one which has already gained acceptance somewhere? The system used by astronomers is the Julian Date. In Meeus, Jean, _Astronomical_Formulae_for_Calculators_, (Willman-Bell, 1985). it says The Julian Day begins at Greenwich *noon*, that is at 12h Universal Time (or 12h Ephemeris Time, and in that case the expression Julian Ephemeris Day is generally used). For example, 1977 April 26.4 = JD 2443259.9. The epoch turns out to be JD 0 == January 1.5, 4713 B.C. (assuming I did the calculation right, but that date sounds about right). I have no idea why this number was chosen (except for a vague memory that it was someone's idea of the time of the creation of the universe). Note that modern dates are up around 2 million. A common convention is to subtract off 2.4 million from these dates. Note that JD 2400000.0 is November 16.5, 1858. The convention of subtracting 2.4 million is the origin of the Modified Julian Day mentioned in another posting: From: nreadwin@micrognosis.co.uk (Neil Readwin) >|> VMS has a really strange one [epoch]. I think it starts on Feb 14, 1758. >It starts on November 17, 1858, which is the base of the Modified Julian Day >system adopted by the Smithsonian Astrophysical Observatory (SAO) in 1957 for >satellite tracking. Meeus's book provides algorithms for conversion from Gregorian Date to Julian Date and back. I've modified what is there slightly to make this more like code than the verbal recipe there. In the following, INT(x) means the integer part (round towards negative infinity: INT(-1.5) == -2). This is not intended to be in any particular programming language though it looks a lot like C. This is untested, so I could easily have translated something wrong from the book. To convert Gregorian (with year -1 == 2 B.C.) to JD Let "y" be the year, "m" be the month (1 to 12), and "d" be the day (including any fraction). Calculate the Julian Day, "jd". if (m <= 2) { y = y - 1; m = m + 12; } if ((y > 1582) OR (y == 1582 AND m > 10) OR (y == 1582 AND m == 10 AND d >= 15)) { a = INT(y/100); b = 2 - a + INT(a/4); } else b = 0; jd = INT(365.25 * y) + INT(30.6001 * (m + 1)) + d + 1720994.5 + b; To convert positive JD to Gregorian (with year -1 == 2 B.C.) Let "jd" be the Julian Day (including fraction). Calculate "day", "month", and "year". z = INT(jd + .5); if (z < 2299161) a = z; else { a0 = INT((z - 1867216.25) / 36524.25); a = z + 1 + a0 - INT(a0/4); } b = a + 1524; c = INT((b - 122.1) / 365.25); d = INT(365.25 * c); e = INT((b - d) / 30.6001); day = b - d - INT(30.6001 * e) + jd + .5 - z; if (e <= 13) month = e - 1; else month = e - 13; if (month <= 2) year = c - 4715; else year = c - 4716; Richard M. Mathews Lietuva laisva = Free Lithuania richard@locus.com Brivu Latviju = Free Latvia lcc!richard@seas.ucla.edu Eesti vabaks = Free Estonia ...!{uunet|ucla-se|turnkey}!lcc!richard