#ifdef	ournix
#include "ournix.h"
#endif
char sccsID[] =
 "@(#) easter.c V1.1 Copyright Julian H. Stacey, Canterbury, November 1977\n" ;
/* This is a table of the dates for Easter day, for the 20th century.
	converted to C language, 1988-09-17, 
	Generates dates for EAster from 1583 onward (inclusive)
	Implementation: algol60 ukc edinburgh compiler
	Documentation:	UKC 2nd year C&C question sheet/handout
			from Dr David Turner (later a Professor at UKC).
	This program generates the same table that almost all the rest
	of the class got, bar 1 or 2, the results were considered correct by David Turner
	The results of the C have not been compared with the results of the Algol
	The question sheet was built from the bible, lots of references to Golden
	Years  & other weird stuff.  I never bothered to read the bible to check it.

38 years after writing this program, 2015-06-02 I dscovered this URL
http://en.wikipedia.org/wiki/Computus Date of Easter

PS FYI See Also
https://en.wikipedia.org/wiki/Ramadan_in_the_United_Kingdom
*/

#include <stdio.h>
#include <stdlib.h>

char	**ARGV ;
int line_count,year,gold_year,century,leap_count,moon_synch,sunday,epact,number;

/* entier:algol integer divide built in function */

	void
suffix(number)
	/* prints a suffix: st,nd,rd, or th, after an integer */
	int number;
	{
	int	suf1,suf2;

	number = abs(number);
	suf1 = number - 10 * (number / 10);
	suf2 = number - 100 * (number / 100);
	if ((suf1 == 0) || (suf1 >= 4) || (suf2 >= 11) && (suf2 <= 13))
		printf("th") ;
	else if ( suf1 == 1 ) printf("st")  ;
	else if ( suf1 == 2 ) printf("nd")  ;
	else printf("rd");
	}

	int
main(argc,argv)
	int argc ; char **argv ;
	{
	int	sp_count ;
	ARGV = argv ;
#ifdef	VSL	/* { */
#include	"../../include/vsl.h"
#endif		/* } */

	line_count = 0;
	for (year = 1950 ; year++ < 2055 ; )
	if (year >1582  )
		{
		/* calculate a date */
		gold_year = ( year % 19 )  + 1;
		century = (year / 100) + 1;
		leap_count = (3 * century / 4) - 12;
		moon_synch = ((8 * century + 5) / 25) - 5;
		sunday = (5 * year / 4) - leap_count - 10;
		epact = (11 * gold_year + 20 + moon_synch - leap_count) % 30 ;
		if ( (epact == 24) || (epact == 25) && (gold_year>11) ) 
			epact += 1;
		number = ( 44 - epact<21) ?  74 - epact : 44 - epact;
		number = number + 7 - ((sunday + number) % 7);

		/* output a date */
		if ( (line_count % 5) == 0 ) putchar('\n');
		if ( number > 31 )
			{
			printf("%2d",number - 31);
			suffix(number - 31);
			printf(" Apr ");
			}
		else
			{
			printf("%2d",number);
			suffix(number);
			printf(" Mar ");
			}
		printf("%4d",year);
		for (sp_count=3 ; sp_count-- ; ) putchar(' ');
		line_count += 1;
		} /* of loop that prints one date per year */
	putchar('\n');
	exit(0);
	}
/*	end of easter program in C	*/

/* Original untouched Algol ICL 2960 version below : {

	'begin'
	'comment'
	   program name :          easter
	           author:         j.h.stacey, keynes college, university of kent at canterbury
	           function:       generates dates for easter from 1583 onward (inclusive)
	           implementation: algol60 ukc edinburgh compiler
	           documentation:  ukc 2nd year c&c question sheet/handout
	  ;
	 
	'integer' count,year,goldyr,century,leapcount,moonsynch,sunday,epact,number;
	 
	'integer' 'procedure' modulus(operand,base);
	     'value' operand,base;
	     'integer' operand,base;
	     modulus:=operand-base*(operand'div'base);
	 
	'procedure' suffix (number);
	     'comment' prints a suffix: st,nd,rd, or th, after an integer;
	     'value'number;
	     'integer' number;
	     'begin'
	          'integer' suf1,suf2;
	          number:=abs(number);
	          suf1:=number-10*entier(number/10);
	          suf2:=number-100*entier(number/100);
	          'if' suf1=0 'or' suf1>=4 'or' suf2>=11 'and' suf2<=13 'then' writetext(<th>) 'else'
	          'if' suf1=1 'then' writetext(<st>) 'else'
	          'if' suf1=2 'then' writetext(<nd>) 'else'
	          writetext(<rd>);
	     'end';
	 
	'comment' main program ;
	     writetext (<this_is_a_table_of_the_dates_for_easter_day,_for_the_20th_century>);
	     newline;
	     count:=0;
	     'for' year := 1901 'step' 1 'until' 2000 'do'
	     'if' year >1582 'then'
	     'begin'
	          'comment' calculate a date;
	          goldyr:=modulus(year,19)+1;
	          century:=entier(year/100)+1;
	          leapcount:=entier(3*century/4)-12;
	          moonsynch:=entier((8*century+5)/25)-5;
	          sunday:=entier(5*year/4)-leapcount-10;
	          epact:=modulus(11*goldyr+20+moonsynch-leapcount,30);
	          'if' epact=24 'or' epact= 25 'and' goldyr>11  'then' epact:=epact+1;
	          number:= 'if' 44-epact<21 'then' 74-epact 'else' 44-epact;
	          number:= number+7-modulus(sunday+number,7);
	 
	          'comment' output a date ;
	          'if' count 'div' 5 = count/5 'then' newline;
	          'if' number>31 'then'
	          'begin'
	               print(number-31,2,0);
	               suffix(number-31);
	               writetext (<_april_>);
	          'end' 'else'
	          'begin'
	               print(number,2,0);
	               suffix(number);
	               writetext (<_march_>);
	          'end';
	          print(year,4,0);
	          spaces(5);
	          count:=count+1;
	    'end' of loop that prints one date per year ;
	writetext (<<2c><15s> end_of_easter_dates_program <c>>);
	'end' of easter program ;
 
} */
