< previous page page_153 next page >

Page 153
Listing 6.10 epact_gregorian ()
/* epact_g.c


   +-------------------------------------------+
   |   Copyright (C) 1995 by Lance W. Latham.  |
   |         All rights reserved.              |
   +-------------------------------------------+


   Returns the value of 'epact' for a given year in the Gregorian calendar system.


   INPUTS:
   1. year, type int. Assumed to be a complete year, not an abbreviated 2-digit
      year. Valid inputs range from 1583 to 32767, assuming a 16-bit integer.


   OUTPUTS:
   1. Returned by routine, type int, the value of epact for the given year.
      Valid values for epact are 1  30. All 30 values may occur in the
      Gregorian calendar.


   NOTES:
   1. The word 'epact' comes from the Greek 'epaktos', meaning 'brought in'.
      The term may signify either:


      1.1. the excess of days in the solar year over the lunar year of
      twelve months, or


      1.2. the age in days of the moon on 1 January of a given year. This
      latter sense is the one used in this routine. This value specifies
      the age of the artificial calendar moon in days at the beginning of
      the calendar year.


   2. This algorithm is based on the one by Donald. E. Knuth, (CACM, v5,
      1962, pp 209210). The CACM paper describes an ALGOL procedure for
      both Gregorian and Julian calendar systems.


   3. This routine returns a value of 0 for years less than 1583. No other
      validation is performed, and no warning is issued in this case.


   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 is not observed (e.g., 1700, 1800, etc.).


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


   7. 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.


   8. Traditionally, the values of 0 and 30 have been used interchangably,
      and have been designated by an asterisk in some applications. This
      routine assigns the value of 30.
*/


 
< previous page page_153 next page >