Calculate date for Easter
Posted: Mon Apr 01, 2013 8:00 pm
Have you ever wondered when Easter will come in the years ahead or in the past. Computing the date of Easter requires finding the remainder of a bunch of integer divisions. For that you need a mod operator that this basic doesn't have. Another def function to the rescue!
Enjoy,
Dale
print "EASTER DATE CALCULATION FOR YEARS 1583 TO 4099"
rem y is a 4 digit year 1583 to 4099
rem d returns the day of the month of Easter
rem m returns the month of Easter
rem Easter Sunday is the Sunday following the Paschal
rem Full Moon (PFM) date for the year
rem This algorithm is an arithmetic interpretation of the 3
rem step Easter Dating Method developed by Ron Mallen 1985.
rem from http://www.assa.org.au/edm
def mod(a,n)=a-(n* int(a/n))
start:
input "year":y
gosub calc
d$=d
print m$;" ";d$;",";y
goto start
rem Subroutine EasterDate (d, m, y)
calc:
FirstDig = int(y / 100) rem first 2 digits of year
Remain19 = mod(y,19) rem remainder of year / 19
rem calculate PFM date
temp = int((FirstDig - 15)/2) + 202 - 11 * Remain19
on FirstDig-20 goto once,done,done,once,once,done,once,once, once,once,once,once,twice,once,once,twice,twice,once,twice, twice
goto done
twice: temp = temp - 1
once: temp = temp - 1
done:
temp = mod(temp,30)
tA = temp + 21
If temp = 29 Then tA = tA - 1
If temp = 28 And Remain19 > 10 Then tA = tA - 1
rem find the next Sunday
tB = mod((tA - 19),7)
tC = mod((40 - FirstDig),4)
If tC = 3 Then tC = tC + 1
If tC > 1 Then tC = tC + 1
temp = mod(y,100)
tD = mod((temp + int(temp / 4)),7)
tE = mod((20 - tB - tC - tD),7) + 1
d = tA + tE rem return the date
If d > 31 Then
d = d - 31
m = 4
m$="April"
else
m = 3
m$="March"
End if
return
Enjoy,
Dale
print "EASTER DATE CALCULATION FOR YEARS 1583 TO 4099"
rem y is a 4 digit year 1583 to 4099
rem d returns the day of the month of Easter
rem m returns the month of Easter
rem Easter Sunday is the Sunday following the Paschal
rem Full Moon (PFM) date for the year
rem This algorithm is an arithmetic interpretation of the 3
rem step Easter Dating Method developed by Ron Mallen 1985.
rem from http://www.assa.org.au/edm
def mod(a,n)=a-(n* int(a/n))
start:
input "year":y
gosub calc
d$=d
print m$;" ";d$;",";y
goto start
rem Subroutine EasterDate (d, m, y)
calc:
FirstDig = int(y / 100) rem first 2 digits of year
Remain19 = mod(y,19) rem remainder of year / 19
rem calculate PFM date
temp = int((FirstDig - 15)/2) + 202 - 11 * Remain19
on FirstDig-20 goto once,done,done,once,once,done,once,once, once,once,once,once,twice,once,once,twice,twice,once,twice, twice
goto done
twice: temp = temp - 1
once: temp = temp - 1
done:
temp = mod(temp,30)
tA = temp + 21
If temp = 29 Then tA = tA - 1
If temp = 28 And Remain19 > 10 Then tA = tA - 1
rem find the next Sunday
tB = mod((tA - 19),7)
tC = mod((40 - FirstDig),4)
If tC = 3 Then tC = tC + 1
If tC > 1 Then tC = tC + 1
temp = mod(y,100)
tD = mod((temp + int(temp / 4)),7)
tE = mod((20 - tB - tC - tD),7) + 1
d = tA + tE rem return the date
If d > 31 Then
d = d - 31
m = 4
m$="April"
else
m = 3
m$="March"
End if
return