source: buchla-68k/orig/DATE/WKDAY.C@ ee49131

Last change on this file since ee49131 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 944 bytes
Line 
1/*
2 =============================================================================
3 wkday.c -- determine the day of the week by Zeller's Congruence
4 Version 1 -- 1988-01-20 -- D.N. Lynx Crowe
5
6 Uses the Gregorian calendar -- accurate from 1752 through 4901 A.D.
7
8 short
9 wkday(year, month, day)
10 short year, month, day;
11
12 year 1752..4901
13 month 1..12 1 = Jan., 2 = Feb., ..., 12 = Dec.
14 day 1..31
15
16 Returns:
17
18 0 - Sunday
19 1 - Monday
20 2 - Tuesday
21 3 - Wednesday
22 4 - Thursday
23 5 - Friday
24 6 - Saturday
25 =============================================================================
26*/
27
28short
29wkday(year, month, day)
30register short year, month, day;
31{
32 register short cen, yinc;
33
34 month -= 2;
35
36 if (month < 1) {
37
38 month += 12;
39 --year;
40 }
41
42 cen = year / 100;
43 yinc = year - (cen * 100);
44
45 return(((((26 * month) - 2) / 10) + day + yinc + (yinc / 4)
46 + (cen / 4) - (2 * cen)) % 7);
47}
Note: See TracBrowser for help on using the repository browser.