ben@hpcvlx.HP.COM (Benjamin Ellsworth) (12/30/88)
I am looking for a bunch of calendar algorithms. I especially need to be able to get the difference between two dates with times. Does anybody know where I can find these algorithms? ----------------------------------------------------------------------- Benjamin Ellsworth | ben%hpcvlx@hplabs.hp.com | INTERNET Hewlett-Packard Company | {backbone}!hplabs!hpcvlx!ben | UUCP 1000 N.E. Circle | (USA) (503) 750-4980 | FAX Corvallis, OR 97330 | (USA) (503) 757-2000 | VOICE ----------------------------------------------------------------------- All relevant disclaimers apply. -----------------------------------------------------------------------
aberg@math.rutgers.edu (Hans Aberg) (12/31/88)
The easiest way to compute the time difference between two dates, and also the date for recurrent phenomena, is to convert the dates into the astronomical Julian Day Number. Here are the rules for those: Rules for computing the Julian day number, used in astronomy: 1. Day 0 = Jan. 1, 4713 B.C., a leap year. (In astronomy, this is the time at 12 PM in Greenwich, with the decimals giving fractions of the day.) 2. Every fourth year, until Oct.4, 1582, is a leap year. After this date the exception 5. below is made. 3. There is no year zero. (In astronomy, year 0 = 1 B.C.) 4. Oct.4, 1582, is directly followed by Oct.15, 1582 (ten days missing), when the Gregorian calendar was introduced. 5. After Oct.15, 1582, the full hundred years 1600, 1700, 1800, and so forth, are only leap years when divisible by 400. 6. Day of week is given by Julian day number modulo 7, Monday = 0, Sunday = 6. These rules, and many others, are to be found in a book, with a title something "... calendars ... ephemeral times ...". Check the reference section in a research library. Hewlett-Packard algorithm, from HP67 manual: Dates between March 1,1900,and February 28, 2100. y' := year-1 if month = 1 or 2 year otherwise. m' := month+13 if month = 1 or 2 month+1 otherwise. d := day. Julian Day # = int(365.25ay')+int(30.6001am')+d+1720982. Hans Aberg Mathematics, Rutgers University