Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.PCS 1/10/84; site ahuta.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!houxm!ahuta!ecl From: ecl@ahuta.UUCP (e.leeper) Newsgroups: net.sources,net.math,net.wanted Subject: Re: Day of Week Alg Message-ID: <206@ahuta.UUCP> Date: Wed, 12-Dec-84 15:52:06 EST Article-I.D.: ahuta.206 Posted: Wed Dec 12 15:52:06 1984 Date-Received: Thu, 13-Dec-84 03:28:06 EST References: <538@uwmacc.UUCP> Organization: AT&T Information Systems Labs, Holmdel NJ Lines: 53 Xref: watmath net.sources:2159 net.math:1642 net.wanted:5340 REFERENCES: <538@uwmacc.UUCP> Re: Perpetual Calendar formula wanted For people asking about perpetual calendar formulae, this one was in the Webster's dictionary when I was growing up. I memorized it and can do it in my head. Except for the fact that I do mod 7 reductions as I go along, the algorithm I use in my head is the same as the following. Break up the date as follows: MONTH DD, CCYY For Pearl Harbor day MONTH = Dec. DD = 7 CC = 19 YY = 41 Let [[x]] be the integer part of x. Let y%z be y mod z. To get the day of the week compute the following: day = (cent(CC) + [[1.25 * YY]] + mon(MONTH) + DD - fudge)%7 cent(19) = 0 cent(18) = 2 cent(17) = 4 cent(16) = 6 month(Apr. or Jul.) = 0 month(Jan. or Oct.) = 1 month(May) = 2 month(Aug.) = 3 month(Feb. or Mar. or Oct.) = 4 month(June) = 5 month(Sept. or Dec.) = 6 fudge = 1 the first two months of a leap year, otherwise 0. if day = 0, then the day is a Saturday, if day = 1, then the day is a Sunday, if day = 2, then the day is a Monday, ... So for Pearl Harbor Day you get day = (0 + 51 + 6 + 7 - 0)%7 = 1 (Evelyn C. Leeper for) Mark R. Leeper ...ihnp4!lznv!mrl