local m =
local EasterData = local function formatEasterError(message, ...) if select('#', ...) > 0 then message = string.format(message, ...) end return "
" .. message .. ""end local function loadEasterYear(year) if not year then return false, formatEasterError(EasterData.errorMissingYear) end local result = tonumber(year) if not result or math.floor(result) ~= result then return false, formatEasterError(EasterData.errorInvalidYear, year) end return true, resultend local function loadEasterMethod(method, year) local result = EasterData.defaultMethod if method then result = EasterData.methods[method] if not result then return false, formatEasterError(EasterData.errorInvalidMethod, method) end end if year < 1583 then result = 1 end return true, resultend local function loadEasterOffset(day) if not day then return true, "" end local data = EasterData.relativeDates local offset = tonumber(day) if not offset then offset = data[day] end if not offset or offset ~= math.floor(offset) or offset < EasterData.minimumOffset or offset > EasterData.maximumOffset then return false, formatEasterError(EasterData.errorInvalidOffset, day) end if offset < -1 then return true, string.format(" %d days", offset) elseif offset0 then return true, "" elseif offset
EasterData.noFormat then return true, nil elseif not fmt then return true, EasterData.defaultFormat else return true, fmt endend --local function calculateEasterDate(year, method) if year < 326 or year > 4099 then -- Easter dates are valid for years between 326 and 4099 -- Method 2 would have to support dates in June thereafter return 0, formatEasterError(EasterData.errorYearOutOfRange, year) end if year < 1583 and method ~= 1 then -- Western or Orthodox Easter is valid since 1583 return 0, formatEasterError(EasterData.errorIncorrectMethod, year) end -- intermediate result local firstDig = math.floor(year / 100) local remain19 = year % 19 local temp = 0 -- table A to E results local tA = 0 local tB = 0 local tC = 0 local tD = 0 local tE = 0 -- Easter Sunday day local d = 0 if method
2 then -- calculate PFM date tA = ((225 - 11 * remain19) % 30) + 21 -- find the next Sunday tB = (tA - 19) % 7 tC = (40 - firstDig) % 7 temp = year % 100 tD = (temp + math.floor(temp / 4)) % 7 tE = ((20 - tB - tC - tD) % 7) + 1 d = tA + tE if method
3 then -- calculate PFM date temp = math.floor((firstDig - 15) / 2) + 202 - 11 * remain19 if firstDig > 26 then temp = temp - 1 end if firstDig > 38 then temp = temp - 1 end if firstDig
24 or firstDig
33 or firstDig
37 then temp = temp - 1 end temp = temp % 30 tA = temp + 21 if temp
28 and remain19 > 10 then tA = tA - 1 end -- find the next Sunday tB = (tA - 19) % 7 tC = (40 - firstDig) % 4 if tC
0 then return day end local result = string.format("%04d-%02d-%02d%s", year, month, day, offset) if format then result = mw.language.getContentLanguage:formatDate(format, result) end return resultend m[EasterData.apiEaster] = function (frame) return Easter(frame.args)end return m