< previous page page_151 next page >

Page 151
6.2.3.1.2.1.3
Epact Functions
This section considers several different functions (see listings at end of chapter) for implementing epact. The calculation for the Gregorian calendar is different than the calculation for the Julian calendar.
Historically, the term ''epact" has been assigned several meanings. For our purposes here, epact defines the age of the (artificial) moon in days on the first day of the year. Medieval calculations of Easter date made heavy use of this function.
(continued)
Listing 6.8
       The fact that the letters normally follow one another in a cycle
       is due to the fact that a common year contains 365 days, which
       causes the following year to start with the next DOW, since 365
       = (52 * 7) + 1. The intercalation of a 'leap day' causes this
       normal 'one-up' cycle to 'leap' an additional letter in the cycle.
       This 'leap' of a letter in the ecclesiastical tables is the original
       source of the term 'leap' year.


       The routine uses these facts, but for the sake of execution speed
       and maintainability, simply incorporates the relationships into two
       arrays, saving the unnecessary repetition of the mathematical
       operations.
    3. In the event of an error, the length of the string returned by the
       routine is zero. This condition may be tested by the 'strlen ()'
       function.
    4. Adequate space should be allowed in the calling routine for storage
       of the returned string. This length is 3 characters, including the
       terminating null returned as part of a string.
*/


#include <stdio.h>
#include "scdtl_2.h"


char *dominical_letter (int year)
{
   char *letter_1 [7] = {"A ", "G ", "F ", "E ", "D ", "C ", "B "};
   char *letter_2 [7] = {"AG", "GF", "FE", "ED", "DC", "CB", "BA"};
   int y;


   y = year_type (year);


   if ((y > 0) && (y < 8))             /* common year */
      return (letter_1 [y - 1]);
   else
      {
      if ((y > 7) && (y < 15))         /* leap year */
         return (letter_2 [y - 8]);
      else
         return (NULL);                /* error */
      }
}


 
< previous page page_151 next page >