"use strict"; // Meeus/Jones/Butcher algorithm for the date of Western (Gregorian) Easter, as given in // Jean Meeus, "Astronomical Algorithms", 2nd ed. (Willmann-Bell, 1998), chapter 8. No host // clock, no Date.now(), no time zone database; pure integer arithmetic on the year. function easterGregorian(year) { const a = year % 19; const b = Math.floor(year / 100); const c = year % 100; const d = Math.floor(b / 4); const e = b % 4; const f = Math.floor((b + 8) / 25); const g = Math.floor((b - f + 1) / 3); const h = (19 * a + b - d - g + 15) % 30; const i = Math.floor(c / 4); const k = c % 4; const l = (32 + 2 * e + 2 * i - h - k) % 7; const m = Math.floor((a + 11 * h + 22 * l) / 451); const month = Math.floor((h + l - 7 * m + 114) / 31); const day = ((h + l - 7 * m + 114) % 31) + 1; return { year, month, day }; } function pad2(n) { return String(n).padStart(2, "0"); } module.exports = { slug: "easter-date-gregorian", title: "Date of Easter (Western, Gregorian)", deck_category: "dates", description: "Computes the date of Western (Gregorian calendar) Easter Sunday for a given year using the Meeus/Jones/Butcher algorithm.", inputs: [ { name: "year", type: "integer", required: true, min: 1583, description: "Gregorian calendar year (the algorithm is valid from 1583 onward, after the 1582 Gregorian reform)" } ], outputs: [ { name: "easter_date", format: "date", description: "ISO 8601 date of Western Easter Sunday" } ], steps: [ "a = year mod 19.", "b = floor(year / 100); c = year mod 100.", "d = floor(b / 4); e = b mod 4.", "f = floor((b + 8) / 25); g = floor((b - f + 1) / 3).", "h = (19a + b - d - g + 15) mod 30.", "i = floor(c / 4); k = c mod 4.", "l = (32 + 2e + 2i - h - k) mod 7.", "m = floor((a + 11h + 22l) / 451).", "month = floor((h + l - 7m + 114) / 31); day = ((h + l - 7m + 114) mod 31) + 1." ], constants: [], sources: [ { kind: "isbn", value: "978-0943396613", title: "Astronomical Algorithms, 2nd edition, chapter 8 (Easter)", publisher: "Willmann-Bell (Jean Meeus)", retrieved_utc: "2026-09-30T19:41:35Z", note: "the Meeus/Jones/Butcher algorithm for the Gregorian (Western) Easter date, valid from 1583 onward" } ], disclaimer: null, questionText(inputs) { return "What is the date of Western Easter Sunday in " + inputs.year + "?"; }, run(inputs) { if (!Number.isInteger(inputs.year) || inputs.year < 1583) throw new Error("year must be an integer of 1583 or later (the Gregorian reform)"); const e = easterGregorian(inputs.year); const answer = e.year + "-" + pad2(e.month) + "-" + pad2(e.day); return { answer, values: { easter_date: answer } }; }, examples: [ { name: "worked example", inputs: { year: 2026 }, expected: { answer: "2026-04-05" }, check: "2026-04-05 is the widely published date of Easter Sunday for 2026" }, { name: "test vector: year 2000", inputs: { year: 2000 }, expected: { answer: "2000-04-23" }, check: "2000-04-23 is the widely published date of Easter Sunday for 2000" }, { name: "test vector: year 2024", inputs: { year: 2024 }, expected: { answer: "2024-03-31" }, check: "2024-03-31 is the widely published date of Easter Sunday for 2024" } ] };