#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # easter1 easter3 easter5 easter7 # easter2 easter4 easter6 # # This shell archive created: Thu Aug 29 21:02:24 EDT 1996 # echo "Extracting file easter1" sed -e 's/^X//' <<\SHAR_EOF > easter1 XFrom: piet@spc.nl (Piet Brekelmans) XSubject: Easter dates calculation? XDate: Thu, 24 Feb 1994 16:11:10 GMT X XHello, XDoes anyone know of a routine to calculate easter dates? X XI know it's got something to do with moon cycles and spring equinoxes, Xbut isn't there a possibility to calculate them (with some precision) Xfrom one known easter date? X XThanks in advance for any pointers. X-- X---------------------------------------------------------------------- XPiet Brekelmans | hmmmm, let's see ... ehhhh ... | SPC/Company Xpiet@spc.nl | should be something funny ... | Postbus 661 X+31 412043888 | hmmmm, let's see ... ehhhh ... | 5340 AR Oss, NL X X++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ X XFrom: simond@informix.com (Simon David) XDate: 24 Feb 1994 20:22:02 GMT X X>In <1994Feb24.161110.352@spc.nl> piet@spc.nl (Piet Brekelmans) writes: X> X>>Does anyone know of a routine to calculate easter dates? X XHow about this little gem of a shell script, (see recent discussion in comp.sources.d) X X# X# Usage: easter YEAR X# Returns the date of Easter for the year given X# Xif [ ! $# -eq 1 ] Xthen X echo "Usage: $0 year" X exit 1 Xfi Xecho $* '[ddsf[lfp[too early X]Pq]s@1583>@ Xddd19%1+sg100/1+d3*4/12-sx8*5+25/5-sz5*4/lx-10-sdlg11*20+lz+lx-30% Xd[30+]s@0>@d[[1+]s@lg11<@]s@25=@d[1+]s@24=@se44le-d[30+]s@21>@dld+7%-7+ X[March ]smd[31-[April ]sm]s@31<@psnlmPpsn1z>p]splpx' | dc | sed 'N Xy/\n/ /' X# End X XSimon X-- Xsimond@informix.com SHAR_EOF if [ `wc -c < easter1` -ne 1468 ] then echo "Lengths do not match -- Bad Copy of easter1" fi echo "Extracting file easter2" sed -e 's/^X//' <<\SHAR_EOF > easter2 XFrom: mdelaney@informix.com (Dr. SPARC) XSubject: Re: Easter dates calculation? XDate: 24 Feb 94 20:15:22 GMT X XIn <1994Feb24.161110.352@spc.nl> piet@spc.nl (Piet Brekelmans) writes: X X>Does anyone know of a routine to calculate easter dates? X XKind of. X X X>I know it's got something to do with moon cycles and spring equinoxes, X>but isn't there a possibility to calculate them (with some precision) X>from one known easter date? X XYup, the attached code uses a table to look up the dates of the Xfull moon; the hard part was calculating the date of the following XSunday. X X - Mark X X==================== CUT HERE =================================== X X#include X X#define MARCH 3 X#define APRIL 4 X X#define LEAP(year) ((year%4 == 0) && (year%100 != 0) || (year%400 == 0)) X Xint juldays[13] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; X X/* I got this from the back of some desk calendar. */ Xstruct paschal_plate X{ X int pa_month; X int pa_day X} paschal_tab[] = { X { APRIL, 14 }, X { APRIL, 3 }, X { MARCH, 23 }, X { APRIL, 11 }, X { MARCH, 31 }, X { APRIL, 18 }, X { APRIL, 8 }, X { MARCH, 28 }, X { APRIL, 16 }, X { APRIL, 5 }, X { MARCH, 25 }, X { APRIL, 13 }, X { APRIL, 2 }, X { MARCH, 22 }, X { APRIL, 10 }, X { MARCH, 30 }, X { APRIL, 17 }, X { APRIL, 7 }, X { MARCH, 27 }, X}; X X/* local functions */ Xvoid julian2day(); Xvoid easter(); Xint paschal(); Xint weekday(); Xint julianday(); X X/* X * just a demo main to show usage of the easter function X */ Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X int year, i; X int month, day; X X if (argc < 2) X { X fprintf (stderr, "Usage: %s year [ ... ]\n", argv[0]); X exit(1); X } X X for (i = 1; i < argc; i++) X { X year = atoi(argv[i]); X if (year == 0) X { X fprintf(stderr, "I think something went wrong\n"); X exit(1); X } X easter (year, &month, &day); X printf ("%02d/%02d/%04d\n", month, day, year); X } X} X X/************************************************************/ X Xvoid easter(year, month, mday) Xint year; Xint *month, *mday; X{ X int wday, jday; X X /* X * first get the date of the full moon that this is all based on X */ X paschal(year, month, mday); X X X /* X * Easter is the first Sunday after that full moon, so we need to X * know what day of the week that full moon is this year. X */ X wday=weekday(year, *month, *mday); X X X /* X * now we need to add the number of days to the next Sunday, it X * is easier to do this in julian days, so I convert this to julian X * days, add the difference, and then convert it back again. X */ X jday=julianday(year, *month, *mday); X if (wday == 7) X jday+=7; X else X jday+=(7-wday); X julian2day(year, jday, month, mday); X} X X X/************************************************************/ X Xpaschal (year, month, day) Xint year, *month, *day; X{ X *month = paschal_tab[year % 19].pa_month; X *day = paschal_tab[year % 19].pa_day; X} X X X/* ================================================================== X * The code from here down was taken from the weekday program by X * Marcel J.E. Mol (version 3.40). I removed some error checking X * code of his because I new the limits of my Paschal table. X * ================================================================== X */ X X/* X * weekday -- returns the day of the week number based on the given X * year, month and day of the month value. X */ Xint weekday(year, month, day) Xint year, month, day; X{ X register int dow; X X dow = 6 + /* the magic number */ X year + /* shift a day each year */ X year/4 - year/100 + year/400 + /* shift a day each leap year */ X juldays[month] + day; /* day of year */ X X if ((month < 3) && LEAP(year)) /* first two months of leap don't */ X dow--; /* have the extra leap shift */ X X dow %= 7; X return (dow == 0) ? 7 : dow; /* convert 0 to 7 */ X X} /* weekday */ X X X X/* X * julian2day -- converts year and julian day value to the corresponding X * month and day of the month values for that year. X * these values are returned in the ouput variables month and day. X */ Xvoid julian2day(year, jday, month, day) Xint year, jday; Xint *month, *day; X{ X int leap; X X leap = LEAP(year) ? 1 : 0; X if (jday > 365+leap || jday <= 0) { X fprintf(stderr, "error in julian date %d.%d\n", year, jday); X exit(8); X } X X if (jday <= 31) { X *month = 1; X *day = jday; X return; X } X X jday -= leap; X if (jday <= 59) { X *month = 2; X *day = jday - 31 + leap; X } X else if (jday <= 90) { X *month = 3; X *day = jday - 59; X } X else if (jday <= 120) { X *month = 4; X *day = jday - 90; X } X else if (jday <= 151) { X *month = 5; X *day = jday - 120; X } X else if (jday <= 181) { X *month = 6; X *day = jday - 151; X } X else if (jday <= 212) { X *month = 7; X *day = jday - 181; X } X else if (jday <= 243) { X *month = 8; X *day = jday - 212; X } X else if (jday <= 273) { X *month = 9; X *day = jday - 243; X } X else if (jday <= 304) { X *month = 10; X *day = jday - 273; X } X else if (jday <= 334) { X *month = 11; X *day = jday - 304; X } X else { X *month = 12; X *day = jday - 334; X } X X return; X X} /* julian2day */ X X X X/* X * julianday -- converts a year, mont and day value the corresponding julian X * day number of that year. X * the julian day is passed as a return value. X */ Xint julianday(year, month, day) Xint year, month, day; X{ X register int doy; X X doy = juldays[month]; X if ((month > 2) && LEAP(year)) X doy++; X doy += day; X X return doy; X X} /* julianday */ X X=========================== CUT HERE ============================= X-- XMark A. Delaney mdelaney@informix.com XPHONE: (415) 926-6369 FAX: (415) 926-6571 XInformix Software, 4100 Bohannon Drive, Menlo Park, CA 94025 XGCS d+ p- c+(++) l u++ e++(-) m++(+)@ s/+ n++(-) h- f+ g+ w+ t+ r y++ SHAR_EOF if [ `wc -c < easter2` -ne 6077 ] then echo "Lengths do not match -- Bad Copy of easter2" fi echo "Extracting file easter3" sed -e 's/^X//' <<\SHAR_EOF > easter3 XFrom: snorri@strengur.is (Snorri Bergmann) XSubject: Re: Easter dates calculation? XDate: 25 Feb 1994 12:38:08 -0500 X X# The function calc_easters(y) calculates the date of X# easters for a given year in the range 1900 - 2099 (both X# years included). X XFUNCTION calc_easter(y) X X DEFINE y,a,b,c,d,e,f,g SMALLINT X X LET a = y - 1900 X LET b = a mod 19 X LET c = (7 * b + 1) / 19 X LET d = (11 * b+ 4 - c) mod 29 X LET e = a / 4 X LET f = (a + e + 31 - d) mod 7 X LET g = 25 - d - f X X IF g > 0 THEN X RETURN MDY(4,g,y) X ELSE X RETURN MDY(3,g+31,y) X END IF X XEND FUNCTION X X-- XSnorri Bergmann | Internet: snorri@strengur.is XStrengur Consulting Engineers | Bang: ...!uunet!strengur.is!snorri XTryggvagata 26 | Phone: +354 1 624700 X101 Reykjavik Iceland | Telefax: +354 1 625785 SHAR_EOF if [ `wc -c < easter3` -ne 855 ] then echo "Lengths do not match -- Bad Copy of easter3" fi echo "Extracting file easter4" sed -e 's/^X//' <<\SHAR_EOF > easter4 XFrom: jparker@hpbs3645.boi.hp.com (Jack Parker) XSubject: Re: Calculate Easter's Date XDate: 11 Mar 1996 12:13:35 -0500 X X> X> Found this (Pascal?) code to calculate Easter's date. How would this X> look in 4gl? What is rem? X XThe Rem looks like a MOD, which is odd since Pascal has a MOD. inint and Xouttext are not standard Pascal - although their purpose is evident. X XDEFINE YR, a, b, c, d, e, x, y, t INTEGER X XPROMPT "Which year (Enter 0 to stop) ? " FOR YR X XWHILE YR != 0 X X LET a = YR MOD 19 X LET b = YR MOD 4 X LET c = YR MOD 7 X X CASE X WHEN YR < 1700 X ERROR "Year to small" X WHEN YR < 1800 X LET x = 23 X LET y = 3 X WHEN YR < 1900 X LET x = 23 X LET y = 4 X WHEN YR < 2100 X LET x = 24 X LET y = 5 X WHEN YR < 2200 X LET x = 24 X LET y = 6 X WHEN YR < 2300 X LET x = 25 X LET y = 0 X OTHERWISE X error "Annee trop grande" X #error "Year to big" X END CASE X LET d = (19 * a + x) MOD 30 X LET e = (2 * b + 4 * c + 6 * d + y) MOD 7 X LET t = d + e + 22 X DISPLAY "In ", YR X IF t < 31 THEN X DISPLAY "Easter is on March ", t X ELSE X LET t = t - 31 X IF t = 26 THEN X LET t = 19 X END IF X IF t = 25 AND d = 28 AND e = 6 AND a > 10 THEN X LET t = 18 X END IF X DISPLAY "Easter is on April ", t X END IF X X PROMPT "Which year (Enter 0 to stop) ? " FOR YR X XEND WHILE X XJust tried this for 1996 - it gave the right answer. Thanks, I haven't done XPascal for ages. X Xcheers Xj. X X_____________________________________________________________________________ XJack Parker - Hewlett Packard, DMD/IS Boise, Idaho, USA Xjparker@hpbs3645.boi.hp.com X_____________________________________________________________________________ X X If anything can go wrong, fix it. To hell with Murphy. X_____________________________________________________________________________ X Any opinions expressed herein are my own and not those of my employers. X_____________________________________________________________________________ SHAR_EOF if [ `wc -c < easter4` -ne 1991 ] then echo "Lengths do not match -- Bad Copy of easter4" fi echo "Extracting file easter5" sed -e 's/^X//' <<\SHAR_EOF > easter5 XFrom: Catalin Badea XSubject: Re: Calculate Easter's Date XDate: 13 Mar 1996 19:12:07 GMT X Xloudelon@vianet.on.ca (Louis DeLongchamp) wrote: X>Found this (Pascal?) code to calculate Easter's date. How would this X>look in 4gl? What is rem? X> X> integer year, a, b, c, d, e, x, y, t ; X> cut short X Xrem is the remainder of a division. 4gl calls it a modulus and uses the Xmod function. X XHere's the Pascal code written in 4GL: X X X# Figure out Easter date for given year X Xmain Xdefine X a, b, c, d, e, x, y, t integer, X aMonth, aYear integer, X easterDate date X Xwhile true X prompt "Which year (Enter 0 to stop) ? " for aYear X if aYear = 0 then exit while end if X X let a = rem (aYear, 19) X let b = rem (aYear, 4) X let c = rem (aYear, 7) X X case X when aYear < 1700 display "Year too small" ; continue while X when aYear < 1800 let x = 23 ; let y = 3 X when aYear < 1900 let x = 23 ; let y = 4 X when aYear < 2100 let x = 24 ; let y = 5 X when aYear < 2200 let x = 24 ; let y = 6 X when aYear < 2300 let x = 25 ; let y = 0 X otherwise display "Year too large" ; continue while X end case X X let d = rem (19 * a + x, 30) X let e = rem (2 * b + 4 * c + 6 * d + y, 7) X let t = d + e + 22 X X if t <= 31 then X let aMonth = 3 # March X else X let t = t - 31 X if t = 26 then let t = 19 end if X if t = 25 and d = 28 and e = 6 and a > 10 then let t = 18 end if X let aMonth = 4 # April X end if X X let easterDate = mdy(aMonth,t,aYear) X X display "Easter is on ", easterDate using "mmm dd, yyyy" X Xend while X Xend main X X Xfunction rem(a,b) # Figure out remainder Xdefine a,b,c integer X Xlet c = a mod b Xreturn c X Xend function X X XCatalin. X X X-- X========================================================================= X Catalin Badea _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/ _/_/_/ X _/ _/ _/ _/ _/_/ _/ X Senior Technical Architect _/ _/_/ _/ _/_/_/ _/ _/_/_/ X _/ _/ _/ _/ _/ _/ X Tecsys Inc. _/ _/_/_/ _/_/_/ _/_/_/ _/ _/_/_/ X===== cat@tecsys.com =========== include system "disclaimer.4gh" ===== X== http://www.virtualmarketplace.com/LEVEL3/ITEC/TECSYSE/TECSYSE.HP === X X SHAR_EOF if [ `wc -c < easter5` -ne 2348 ] then echo "Lengths do not match -- Bad Copy of easter5" fi echo "Extracting file easter6" sed -e 's/^X//' <<\SHAR_EOF > easter6 XFrom: loudelon@ViaNet.on.ca (Louis DeLongchamp) XSubject: Source for Easter calculation XDate: Wed, 13 Mar 1996 07:04:56 -0500 X XHere is the content of what I believe was a web page I came accross. The Xaddress included will guide you to the source I'm sure. X Xhttp://epsom.jsp.umontreal.ca/~bourqueg/ift1010/exe/easter.sim X Xbegin X X ! Ce programme calcule la date de Paques. L'algorithme est X ! se trouve dans Kirkerud, page 64, probleme 3.11.6; X X integer year, a, b, c, d, e, x, y, t ; X X outimage ; X outtext ("Programme corrige par V. Godin et G. Bourque") ; X outtext ("Nous esperons que vous appreciez notre travail acharne") ; X outimage ; X outimage ; X X outtext ("Quelle annee (Tapez 0 pour arreter) ? ") ; X breakoutimage ; X year := inint ; X X while year <> 0 do begin X X a := rem (year, 19) ; X b := rem (year, 4) ; X c := rem (year, 7) ; X X if year < 1700 then error ("Annee trop petite") X else if year < 1800 then begin x := 23 ; y := 3 end X else if year < 1900 then begin x := 23 ; y := 4 end X else if year < 2100 then begin x := 24 ; y := 5 end X else if year < 2200 then begin x := 24 ; y := 6 end X else if year < 2300 then begin x := 25 ; y := 0 end X else error ("Annee trop grande") ; X X d := rem (19 * a + x, 30) ; X e := rem (2 * b + 4 * c + 6 * d + y, 7) ; X t := d + e + 22 ; X X outtext ("En ") ; outint (year, 0) ; X outtext (" Paques tombe le ") ; X X if t <= 31 then begin ! nous sommes en mars ; X outint (t, 0) ; outtext (" mars") X end X else begin ! nous sommes en avril ; X t := t - 31 ; X if t = 26 then t := 19 ; ! premiere exception ; X if t = 25 and d = 28 and e = 6 and a > 10 ! deuxieme exception ; X then t := 18 ; X outint (t, 0) ; outtext (" avril") X end ; X outimage ; outimage ; X X outtext ("Quelle annee ? ") ; X breakoutimage ; X year := inint X X end de la boucle while X Xend XLouis DeLongchamp X165 Tanguay Ave. XSudbury, Ontario P3C 5G4 X(705)675-5895 Xloudelon@vianet.on.ca SHAR_EOF if [ `wc -c < easter6` -ne 2083 ] then echo "Lengths do not match -- Bad Copy of easter6" fi echo "Extracting file easter7" sed -e 's/^X//' <<\SHAR_EOF > easter7 XFrom: loudelon@ViaNet.on.ca (Louis DeLongchamp) XSubject: English Source for Easter calculation XDate: Thu, 14 Mar 1996 08:05:53 -0500 X XHere is the 'english' version as requested. X XAnd I received the following comment which I did not verify: X X>BTW consider the year 2000 in this. X> X>------------------------------------------------------------------- X> /\ \ \ | Albert Dekker X> / \ \ \ \ | taurus@glo.be X> /____\ \ \____ ___ ___\_ | AD@te6.siemens.be X> / \ \ \ \ \__\ \ \ | Nijlen/Antwerp-Belgium X>/ \ \ \___\ \___ \ \__ | www2.cyberkafee.be/~adekker X>------------------------------------------------------------------- X> X X begin X ! This program calculates the Easter date. The algorithm X ! can be found in Kirkerud, page 64, problem 3.11.6; X X integer year, a, b, c, d, e, x, y, t ; X X outimage ; X outtext ("Program corrected by V. Godin and G. Bourque") ; X outtext ("We hope you appreciate our intense labor") ; X outimage ; X outimage ; X X outtext ("Which year (Enter 0 to stop) ? ") ; X breakoutimage ; X year := inint ; X X while year <> 0 do begin X X a := rem (year, 19) ; X b := rem (year, 4) ; X c := rem (year, 7) ; X X if year < 1700 then error ("Year too small") X else if year < 1800 then begin x := 23 ; y := 3 end X else if year < 1900 then begin x := 23 ; y := 4 end X else if year < 2100 then begin x := 24 ; y := 5 end X else if year < 2200 then begin x := 24 ; y := 6 end X else if year < 2300 then begin x := 25 ; y := 0 end X else error ("Year too big") ; X X d := rem (19 * a + x, 30) ; X e := rem (2 * b + 4 * c + 6 * d + y, 7) ; X t := d + e + 22 ; X X outtext ("In ") ; outint (year, 0) ; X outtext (" Easter is on ") ; X X if t <= 31 then begin ! we are in March ; X outint (t, 0) ; outtext (" March") X end X else begin ! we are in April ; X t := t - 31 ; X if t = 26 then t := 19 ; ! first exception ; X if t = 25 and d = 28 and e = 6 and a > 10 ! second exception ; X then t := 18 ; X outint (t, 0) ; outtext (" April") X end ; X outimage ; outimage ; X X outtext ("Which year ? ") ; X breakoutimage ; X year := inint X X end of the while loop X X end XLouis DeLongchamp X165 Tanguay Ave. XSudbury, Ontario P3C 5G4 X(705)675-5895 Xloudelon@vianet.on.ca X SHAR_EOF if [ `wc -c < easter7` -ne 2534 ] then echo "Lengths do not match -- Bad Copy of easter7" fi echo "Done." exit 0