How to calculate Easter Day for a specified year (Views: 28)
Problem/Question/Abstract: How to calculate Easter Day for a specified year Answer: function Easter(Year: Integer): TDateTime; var nMonth, nDay, nMoon, nEpact, nSunday, nGold, nCent, nCorx, nCorz: Integer; begin { The Golden Number of the year in the 19 year Metonic Cycle: } nGold := (Year mod 19) + 1; { Calculate the Century: } nCent := (Year div 100) + 1; { Number of years in which leap year was dropped in order to keep in step with the sun: } nCorx := (3 * nCent) div 4 - 12; { Special correction to syncronize Easter with moon's orbit: } nCorz := (8 * nCent + 5) div 25 - 5; { Find Sunday: } nSunday := (Longint(5) * Year) div 4 - nCorx - 10; { To prevent overflow at year 6554} { Set Epact - specifies occurrence of full moon: } nEpact := (11 * nGold + 20 + nCorz - nCorx) mod 30; if nEpact < 0 then nEpact := nEpact + 30; if ((nEpact = 25) and (nGold > 11)) or (nEpact = 24) then nEpact := nEpact + 1; { Find Full Moon: } nMoon := 44 - nEpact; if nMoon < 21 then nMoon := nMoon + 30; { Advance to Sunday: } nMoon := nMoon + 7 - ((nSunday + nMoon) mod 7); if nMoon > 31 then begin nMonth := 4; nDay := nMoon - 31; end else begin nMonth := 3; nDay := nMoon; end; Easter := EncodeDate(Year, nMonth, nDay); end; |