Author: Tomas Rutkauskas
How to calculate Easter Day for a specified year
Answer:
1 function Easter(Year: Integer): TDateTime;
2 var3 nMonth, nDay, nMoon, nEpact, nSunday, nGold, nCent, nCorx, nCorz: Integer;
4 begin5 { The Golden Number of the year in the 19 year Metonic Cycle: }6 nGold := (Year mod 19) + 1;
7 { Calculate the Century: }8 nCent := (Year div 100) + 1;
9 { Number of years in which leap year was dropped in order to keep in step with 10 the sun: }11 nCorx := (3 * nCent) div 4 - 12;
12 { Special correction to syncronize Easter with moon's orbit: }13 nCorz := (8 * nCent + 5) div 25 - 5;
14 { Find Sunday: }15 nSunday := (Longint(5) * Year) div 4 - nCorx - 10; { To prevent overflow at year 16 6554}17 { Set Epact - specifies occurrence of full moon: }18 nEpact := (11 * nGold + 20 + nCorz - nCorx) mod 30;
19 if nEpact < 0 then20 nEpact := nEpact + 30;
21 if ((nEpact = 25) and (nGold > 11)) or (nEpact = 24) then22 nEpact := nEpact + 1;
23 { Find Full Moon: }24 nMoon := 44 - nEpact;
25 if nMoon < 21 then26 nMoon := nMoon + 30;
27 { Advance to Sunday: }28 nMoon := nMoon + 7 - ((nSunday + nMoon) mod 7);
29 if nMoon > 31 then30 begin31 nMonth := 4;
32 nDay := nMoon - 31;
33 end34 else35 begin36 nMonth := 3;
37 nDay := nMoon;
38 end;
39 Easter := EncodeDate(Year, nMonth, nDay);
40 end;