|
|
|
| Listing 6.19 easter_gregorian_obeirne_1 () | |
|
|
|
|
/* eastrgol.c
+-------------------------------------------+
| Copyright (C) 1995 by Lance W. Latham. |
| All rights reserved. |
+-------------------------------------------+
Routine for Gregorian Easter from T. H. O'Beirne, "Puzzles and
Paradoxes". This is the first of two alternative procedures given.
INPUTS:
1. year, type int. the year in the Gregorian calendar for which
the date of Easter is desired. Valid values are 1583 to INT_MAX.
OUTPUTS:
1. Returned by routine, a DATE_INFO structure containing the date
of Easter for the input year. Valid values for month and day are
such that no date can occur before 22 March or after 25 April.
NOTES:
1. This routine is based on Table 10a, page 180 of O'Beirne, and is the set of
'upper rules' which emphasizes explanation rather than simplicity of computation.
2. O'Beirne states (page 178) that the algorithm is based on a procedure which
was first given in "Nature" in 1876 by an anonymous New York correspondent.
3. This routine returns a date of all zeroes for years less than 1583.
No other validation is performed, and no warning is issued in this case.
*/
#include "dateinfo.h"
struct DATE_INFO easter_gregorian_obeirne_1 (int year)
{
int a, b, c, d, e, g, h, m, i, k, f, n, p;
struct DATE_INFO date;
date.year = 0;
date.month = 0;
date.day = 0;
if (year < 1583)
return (date);
a = year % 19;
b = year / 100;
c = year % 100;
d = b / 4;
e = b % 4;
g = ((8 * b) + 13) / 25;
h = ((19 * a) + b - d - g + 15) % 30;
m = (a + (11 * h)) / 319;
i = c / 4;
k = c % 4;
f = ((2 * e) + (2 * i) - k - h + m + 32) % 7;
n = (h - m + f + 90) / 25;
p = (h - m + f + n + 19) % 32;
date.year = year;
date.month = n;
date.day = p;
return (date);
}
|
|
|
|
|
|
|
|