Easter calculation (Gregorian only)
Posted: Tue Dec 12, 2023 4:12 am
In case anyone needs this (I know you've all been waiting for this):
Returns the date of the Easter sunday for the Gregorian calendar. Working on calculating the Julian one, but it somehow doesn't work (which is odd, because it should be easier).
Code: Select all
Procedure.s Easter(Year.w)
Protected Easter.a,a.a=Mod(Year,19),b.a=Mod(Year,4),c.a=Mod(Year,7),k.a=Int(Year/100),p.a=Int((8*k+13)/25),q.a=Int(k/4),M.a=Mod(15+k-p-q,30),d.a=Mod(19*a+M,30),N.a=Mod(4+k-q,7),e.a=Mod(2*b+4*c+6*d+N,7)
If d=29 And e=6
ProcedureReturn "19.04."+Str(Year)
ElseIf d=28 And e=6 And Mod(11*M+11,30)<19
ProcedureReturn "18.04."+Str(Year)
Else
Easter=22+d+e
EndIf
If Easter>31
ProcedureReturn RSet(Str(Easter-31),2,"0")+".04."+Str(Year)
Else
ProcedureReturn RSet(Str(Easter),2,"0")+".03."+Str(Year)
EndIf
EndProcedure
For Temp=1900 To 2050
Debug Easter(Temp)
Next