From:	SMTP%"mrshort@esvx12.es.dupont.com" 31-AUG-1993 12:08:43.40
To:	EVERHART
CC:	
Subj:	Re: LIB$DAY in DCL?

X-Newsgroups: comp.os.vms
From: mrshort@esvx12.es.dupont.com
Subject: Re: LIB$DAY in DCL?
Message-ID: <1993Aug31.121327.3781@es.dupont.com>
Sender: news@es.dupont.com (USENET News System)
Nntp-Posting-Host: esvx12.es.dupont.com
Reply-To: mrshort@esvx12.es.dupont.com
Organization: DuPont (Opinions are those of the writer only)
Date: Tue, 31 Aug 1993 12:13:27 GMT
Lines: 78
To: Info-VAX@KL.SRI.COM
X-Gateway-Source-Info: USENET

Here is a version in c, plus a reference to the method.


/* EASTER.C--Calculate the date of Easter 

The method used is described in chapter 4 of
Astronomical Formulae for Calculators, 4th edition
by Jean Meeus

After creating the executable, create a symbol 

$ easter :== $disk:[dire]easter

Usage is 

$ easter year [range]

Where range is optional; a range of 10 would cause the
program to calculate easter for the year given and the next 9 years.

*/
#include <stdlib.h>
#include <stdio.h>
#define GREGORIAN 1583

char * Moname[] = { "Jan", "Feb", "March", "April" } ;

int main(int argc, char *argv[])
{
   int a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, y ;
   int rg = 1, incr = 1, icnt = 0 ;
   if (argc < 2) {
     printf("Usage: easter year [range]") ;
     exit(0) ;
   }
   y = atoi(argv[1]) ;
   if (argc > 2) rg = atoi(argv[2]) ;
   if (y < GREGORIAN) {
     printf("You have given the year as %d.\n", y) ;
     printf("Easter for years prior to %d are not computable by this procedure.",GREGORIAN) ;
     exit(0) ;
   }
   if (y + rg < GREGORIAN) {
     printf("In the range you have given there is at least one date\n") ;
     printf("before %d the range will be adjusted to end at %d.\n",GREGORIAN, GREGORIAN) ;
     rg = GREGORIAN - y - 1 ;
   }
   if (rg < 0) {
     rg = abs(rg) ;
     incr = -1 ;
   }
   if (rg == 0) rg = 1 ;
   rg = rg - 1 ;
   y = atoi(argv[1]) ;
   while (icnt <= rg) {
     a = y % 19 ;
     b = y / 100 ;
     c = y % 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 ;
     l = (32 + 2*e + 2*i - h - k) % 7 ;
     m = (a + 11*h + 22*l) / 451 ;
     n = (h + l - 7*m + 114) / 31 ;
     p = (h + l - 7*m + 114) % 31 ;
     printf("\nFor the year %d Easter is %s %d.\n", y, Moname[n-1], p+1) ;
     icnt = icnt + 1 ;
     y = y + incr ;
  }
  exit(0) ;
}
Dr. Michael R. Short          Internet  mrshort@esvax.dnet.dupont.com
DuPont Experimental Station   Phone     USA (302)695-1942
Wilmington, DE 19880-0320     FAX       USA (302)695-9658

