|
|
|
|
|
|
|
6.2.3.1.2.1.3.3 epact_julian () |
|
|
|
|
|
|
|
|
This routine (Listing 6.11) returns the value of epact for a given year in the Julian calendar system. |
|
|
|
|
| Listing 6.10 | |
|
|
|
|
int epact_gregorian (int year)
{
int epact;
long y, g, c, x, z, e, el;
if (year < 1583)
return (0);
y = (long) year;
g = (y - ((y / 19L) * 19L)) + 1L;
c = (y / 100L) + 1L;
x = ((3L * c) / 4L) - 12L;
z = (((8L * c) + 5L) / 25L) - 5L;
el = ((11L * g) + 20L + z - x);
e = el - ((el / 30L) * 30L);
/*
The value of 'e' may be negative. The case of year = 14250, e.g.,
produces values of g = 1, z = 40 and x = 95. The value of el is thus
-24, and the 'mod' code fails to return the proper positive result.
The following correction produces a positive value, modulo 30, for 'e'.
*/
if (e <= 0L)
e += 30L;
epact = (int) e;
return (epact);
}
|
|
|
|
|
|
|
| Listing 6.11 epact_julian () | |
|
|
|
|
/* epact_j.c
+-------------------------------------------+
| Copyright (C) 1995 by Lance W. Latham. |
| All rights reserved. |
+-------------------------------------------+
Returns the value of 'epact' for a given year in the Julian calendar system.
INPUTS:
1. year, type int. Assumed to be a complete year, not an abbreviated 2-digit
year. Valid inputs range from 1 to 1582, assuming a 16-bit integer.
|
|
|
|
|
|
|
|