< previous page page_164 next page >

Page 164
(continued)
Listing 6.17
#include "dateinfo.h"
struct DATE_INFO easter_gregorian_meeus (int year)
{
   int a, b, c, d, e, f, g, h, i, k, x, m, n, p, q;
   struct DATE_INFO date;


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


   if (year < 1583)
      return (date);


   a = year % 19;
   b = year / 100;
   c = year % 100;
   d = b / 4;
   e = b % 4;
   f = (b + 8) / 25;
   g = (b - f + 1) / 3;
   h = ((19 * a) + b - d - g + 15) % 30;
   i = c / 4;
   k = c % 4;
   x = (32 + (2 * e) + (2 * i) - h - k) % 7;
   m = (a + (11 * h) + (22 * x)) / 451;
   q = (h + x - (7 * m) + 114);
   n = q / 31;
   p = q % 31;


   date.year = year;
   date.month = n;
   date.day = (p + 1);


   return (date);
}

Listing 6.18 easter_julian_meeus ()
/* easterjm.c
   +-------------------------------------------+
   |   Copyright (C) 1995 by Lance W. Latham.  |
   |         All rights reserved.              |
   +-------------------------------------------+


   INPUTS:
   1. year, type int, the year in the Julian calendar for which the
      date of Easter is desired. Valid values are 1583 to INT_MAX.
   OUTPUTS:
   1. Returned by routine, a DATE_INFO structure containing the date of
      Easter for the given year.
   NOTES:
   1. This Julian Easter routine is given by Jean Meeus in his book, "Astronomical
      Algorithms", Willmann-Bell, Inc., Richmond, VA, 1991, ISBN 0-943396-35-2, page 69.
      Meeus does not provide a reference for this algorithm.

 
< previous page page_164 next page >