< previous page page_160 next page >

Page 160
(continued)
Listing 6.15
   OUTPUTS:
   1. d, DATE_INFO date indicating the date on which Easter falls for
      the indicated year.


   NOTES:
   1. Easter is defined as 'first Sunday following the first ecclesiastical
      full moon which occurs on, or after, March 21'. Due to perturbations
      in the moon's orbit, the 'calendar moon', and not the 'true', or
      'astronomical' moon, is used for calculation purposes.


   2. This algorithm is based on the one in D. E. Knuth, 'Fundamental Algorithms',
      pages 1556. Knuth lists a citation (CACM, v5, 1962, pp 209210), which is
      also one of his papers. The CACM paper describes an ALGOL procedure for both
      Gregorian and Julian calendar systems. The Gregorian routine listed in the
      1962 paper is virtually identical to this one, with the exception of the
      calculation of the 'Clavian correction' which is:
                z = (c - 16 - (c - 18) / 25) / 3;
      in the 1962 CACM paper.


   3. This routine does not validate the input.


   4. 'Golden number' (g) is the number of the year in the Metonic cycle,
      used to determine the position of the moon.


   5. 'Gregorian correction' (x) is the number of preceding years when leap
      year was not held (e.g., 1700, 1800, etc.).


   6. 'Clavian correction' (z) is a correction for the Metonic cycle of
      about 8 days every 2500 years.


   7. 'Epact' (e) is the age of the calendar moon at the beginning of the
      year, and specifies when full moon occurs.


   8. 'Extra days' (d) specifies when Sunday occurs in March.


   9. The code of the form (x - (x / y) * y) performs the operation of 'x mod y'.
      The value of 'y' is a controlled non-zero value in each case, and the value
      of 'x' is non-negative, so this method works properly as a substitute for
      the integer '%' operator for the type long values in this routine.
*/


#include "scdtl_1.h"


struct DATE_INFO easter_gregorian (int year)
{
   struct DATE_INFO date;
   long y, g, c, x, z, d, e, n, el, nl, dpn;


   y = (long) year;
   g = (y - ((y / 19L) * 19L)) + 1L;
   c = (y / 100L) + 1L;
   x = ((3L * c) / 4L) - 12L;
   z = (((8L * c) + 5L) / 25L) - 5L;
   d = ((5L * y) / 4L) - x - 10L;
   el = ((11L * g) + 20L + z - x);
   e = el - ((el / 30L) * 30L);


 
< previous page page_160 next page >