richard@sequent.UUCP (01/19/84)
Once upon a time, I read an article that described an algorithm to compute the Day-of-the-week when given the date. There were about 6 terms in it, with the anwser coming out to 0=sunday, 1=Monday, ... Obviously, the last thing was a modulo. If anyone in netland happens to know that equation, I'd be gratefully receive such. From thge confused and bleeding fingertips of ...!sequent!richard (Without friction there's no heat, without heat there can't be fire, without fire there's no desire - you're making me hot, hot, hot, hot!)
rogerc@orca.UUCP (Roger M. Christal) (01/19/84)
Here is the algorithm for computing the day of the week for any given date (in this century at least). First, each month is given a number value. January = 1 July = 0 February = 4 August = 3 March = 4 September = 6 April = 0 October = 1 May = 2 November = 4 June = 5 December = 6 When doing the calculation for a leap year, remember to subtract 1 from January or Febuary dates. Add: the year (modulo 1900 or whatever; 1953 means 53) the INT(year/4) (again; 1953 means 53; INT(53/4) = 12) day of month month code (as above) Divide the above answer by 7 and use the remainder as the day of the week; Saturday = 0. Day Of Week = MOD7 ((year) + INT (year / 4) + (day of month) + (month code)) Example: I was born on Easter Sunday, 1947. The date is April 6. year + INT(year/4) + day + month code 47 + 11 + 6 + 0 = 64 MOD7 (64) = 1, or Sunday! Mugs Away, Mate! - - - - - - - - - - - - - - - - - \\\\\\ _________ Doctor Dart - - - - - - - - - - >>>>>>----==(_________)----- - - - - - - - - - - - - - - - - - ////// ..!decvax!tektronix!orca!rogerc
lmc@denelcor.UUCP (Lyle McElhaney) (01/29/84)
Zeller's Congruence furnishes the day of the week for any date. For the kth day of the mth month of the dth year of the cth century, f = (k + [2.6m - .2] + d + [d/4] + [c/4] - 2c ) mod 7 assuming: March is month 1, ... December is month 10, Jan and Feb are months 11 and 12 of the previous year. The square brackets are "greatest integer" truncation functions. The result is 0 for Sunday, ... 6 for Saturday. -- Lyle McElhaney (hao,brl-bmd,nbires,csu-cs,scgvaxd)!denelcor!lmc
sew@minn-ua.UUCP (02/03/84)
#R:orca:-48600:minn-ua:6500001:000:269 minn-ua!sew Feb 1 11:50:00 1984 There are only 16 years left in this century. If UN*X and C are as portable as they seem, many programs which are written now might survive until then ("then" is February 30th 2000 A.D., right?). Is there an efficient algorithm which will work for the next 50 years?