Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!ctrsol!srcsip!tcnet!pwcs!stag!daemon From: dal@syntel.UUCP (Dale Schumacher) Newsgroups: comp.sys.atari.st Subject: Julian Date Message-ID: <1989Jul21.133738.173@stag.UUCP> Date: 21 Jul 89 13:37:38 GMT Sender: daemon@stag.UUCP (The devil himself) Organization: Mindtools ST Access Group Lines: 32 [jms@tardis.Tymnet.COM (Joe Smith) writes...] > In article <061089A1311@syntel.UUCP> dal@syntel.UUCP (Dale Schumacher) writes: > < return( ((146097L * c) >> 2) + > < ((1461L * y) >> 2) + > < (((153L * m) + 2) / 5) + > < d + 1721119L ); > > I love it! One question though, what in the heck is the 1721119 for? > That many days is over 4000 years. That constant should be -68142 if > you want day 1 to be 18-Nov-1858, right? I must admit to not being an expert on date systems, but I don't think that 18-Nov-1858 is supposed to be the base date of the Julian calendar. I found this magic formula in two separate (and apparently unrelated) places, one in BASIC and the other in FORTRAN. The algorithms were slightly different, by they reduced to identical formulae. It has served my purposes well. The base date doesn't really matter much in actual use, since nobody really cares to know "how many days since the Julian base date" but rather "how many days different are these two dates". PS. I received one comment that this was a horribly complex way to determine leap years. I must agree, on the surface, but if this function is already in your library (or should be) for it's numerous other uses, then why not take advantage of it to handle leap years with greater accuracy? \\ / Dale Schumacher 399 Beacon Ave. \\ / (alias: Dalnefre') St. Paul, MN 55104-3527 >< ...umn-cs!midgard.mn.org!syntel!dal United States of America / \\ "What is wanted is not the will to believe, but the will to find out, / \\ which is the exact opposite." -Bertrand Russell