< previous page page_171 next page >

Page 171
(continued)
Listing 6.22
#include "dateinfo.h"


struct DATE_INFO easter_gauss (int year)
{
   int y, century, month, day, a, b, c, d;
   struct DATE_INFO date;


   date.year = 0;
   date.month = 0;
   date.day = 0;


   if ( (year < 1583)) || (year > 2199) )
      return (date);


   y = year;
   century = y / 100;


   switch (century)
          {
          case 15 : a = 22; b = 2; break;
          case 16 : a = 22; b = 2; break;
          case 17 : a = 23; b = 3; break;
          case 18 : a = 23; b = 4; break;
          case 19 : a = 24; b = 5; break;
          case 20 : a = 24; b = 5; break;
          case 21 : a = 24; b = 6; break;
          }


   c = (19 * (y % 19) + a) % 30;
   d = (2 * (y % 4) + 4 * (y % 7) + 6 * c + b) % 7;


   day = 22 + c + d;
   month = 3;


   if (day > 31)
      {
      day = c + d - 9;
      month++;
      }


   If ( ( month == 4) && (day == 26) )
      day = 19;


   if ( ( c == 28) && ( (y % 19) > 10) && (month == 4) && (day == 25) )
      day = 18;


   date.year = y;
   date.month = month;
   date.day = day;


   return (date);
}



 
< previous page page_171 next page >