All,
If (like me) you've always wondered how 'they' decided
when easter is and have written diary apps where you've
scratched your head when it came to allowing for
national/bank holidays; you will find this useful.
I've written it in C, assembler, sql and VB (as well
as the COBOL version below) if anyone is 'that'
interested.
Cheers All
(email: kfmason@tinyonline.co.uk).
------------------------------------------------------
If (like me) you've always wondered how 'they' decided
when easter is and have written diary apps where you've
scratched your head when it came to allowing for
national/bank holidays; you will find this useful.
I've written it in C, assembler, sql and VB (as well
as the COBOL version below) if anyone is 'that'
interested.
Cheers All
(email: kfmason@tinyonline.co.uk).
------------------------------------------------------
Code:
******************************************************
*Easter falls on the First Sunday following the first*
*Full moon that occurs on or after 21 March. This *
*algorithm, attributed to Guass, will return for a *
*given year, >=1583, a value for Easter Sunday in the*
*format MMDD. It returns the date in the same field *
*as the request year. The input year variable is *
*v-year, the output is v-easterday(mmdd). *
******************************************************
WORKING-STORAGE SECTION.
01 V-YEAR PIC S9(04) VALUE ZERO.
01 V-DAY PIC S9(02) VALUE ZERO.
01 V-EASTERDAY PIC S9(04) VALUE ZERO.
01 V-CENTURY PIC S9(02) VALUE ZERO.
01 V-GOLDEN PIC S9(04) VALUE ZERO.
01 V-GREGORIAN PIC S9(04) VALUE ZERO.
01 V-CLAVIAN PIC S9(04) VALUE ZERO.
01 V-FACTOR PIC S9(06) VALUE ZERO.
01 V-EPACT PIC S9(06) VALUE ZERO.
PROCEDURE DIVISION
XX-CALCULATE EASTERDAY.
*******************************************************
* Step 1 Century - Century of requested year. *
* Step 2 Golden - Number of the year in the Metonic*
* Cycle and used to determine the *
* position of the calendar moon. *
* Step 3 Gregorian - Years in which a leap year did *
* notoccur. *
* Step 4 Clavian - Correction for the Metonic Cycle *
* (about 8 days every 2,500 years. *
* Step 5 Factor - Variable for storing intermediate*
* value. *
* Step 6 Epact - Age of the moon on 1 January, *
* used to calc when the full moon *
* occurs. *
*******************************************************
* Step 1
COMPUTE V-CENTURY = (V-YEAR / 100) + 1
* Step 2
COMPUTE V-GOLDEN= FUNCTION MOD(V-YEAR, 19) + 1
* Step 3
COMPUTE V-GREGORIAN = (V-CENTURY * 3) / 4 - 12
* Step 4
COMPUTE V-CLAVIAN
= (V-CENTURY * 8 + 5) / 25 - 5 - V-GREGORIAN
* Step 5
COMPUTE V-FACTOR
= (V-YEAR * 5) / 4 - V-GREGORIAN - 10
* Step 6
COMPUTE V-EPACT
= FUNCTION MOD((V-GOLDEN * 11 + 20 + V-CLAVIAN), 30)
IF V-EPACT = 24
ADD 1 TO V-EPACT
ELSE
IF V-EPACT = 25
IF V-GOLDEN > 11
ADD 1 TO V-EPACT
END-IF
END-IF
END-IF
COMPUTE V-DAY = 44 - V-EPACT
IF V-DAY < 21
ADD 30 TO V-DAY
END-IF
COMPUTE V-DAY
= V-DAY + 7 - (FUNCTION MOD((V-DAY + V-FACTOR), 7))
IF V-DAY <= 31
ADD 300 TO V-DAY GIVING V-EASTERDAY
ELSE
SUBTRACT 31 FROM V-DAY
ADD 400 TO V-DAY GIVING V-EASTERDAY
END-IF
.
XX-EXIT.
EXIT.