Using the code in the Wiki for calculate Easter gives me for 2012 the date of Good Friday on April 7th. But April 7th is Saturday.
I was using this code in an Excel ready-to-print calendar. It's more or less the same code, but with another approach. For 2012, it gives me the correct date of April 6th.
| Code: |
function Holidays_CalculateEaster(year)
golden = (year % 19) + 1
c = math.floor(year/400) + math.floor(8*(math.floor(year/100)+11)/25) - math.floor(year/100)
s = (11 * golden + c) % 30
if (s < 0) then
s = s + 30
end
pfm = os.time{year=year, month=4, day=19} - s * 24 * 60 * 60
if (pfm == os.time{year=year, month=4, day=19}) then
pfm = pfm - 24 * 60 * 60
elseif (pfm == os.time{year=year, month=4, day=18} and golden > 11) then
pfm = pfm - 24 * 60 * 60
end
sunday = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60
friday = sunday - 2 * 24 * 60 * 60
return {year, tonumber(os.date("%m", friday)), tonumber(os.date("%d", friday))}
end
|
PS: Maybe 86400 is better than 24*60*60, but it's more easy to understand.