From 9c0a755767da935dce6bfdaed2f7e11cfd30421a Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Fri, 31 Jul 2026 14:06:33 +0200 Subject: kernel(computus): Gregorian + Julian Easter Anonymous Gregorian (Meeus/Jones/Butcher) for OF+EF; Meeus Julian mapped to the proleptic-Gregorian date for future eastern rites. Verified vs known dates (2000/2024-27, 1583; Orthodox 2023/24) and EXHAUSTIVELY over 1583..9999: every Easter is a Sunday in [Mar22,Apr25]. --- lib/kernel/computus.ml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/kernel/computus.ml (limited to 'lib/kernel/computus.ml') diff --git a/lib/kernel/computus.ml b/lib/kernel/computus.ml new file mode 100644 index 0000000..1f60fb7 --- /dev/null +++ b/lib/kernel/computus.ml @@ -0,0 +1,31 @@ +let mk y m d = + match Date.make ~year:y ~month:m ~day:d with + | Ok t -> t + | Error e -> failwith ("computus: " ^ e) + +(* Anonymous Gregorian algorithm (Meeus / Jones / Butcher). *) +let gregorian_easter y = + let a = y mod 19 in + let b = y / 100 and c = y mod 100 in + let d = b / 4 and e = b mod 4 in + let f = (b + 8) / 25 in + let g = (b - f + 1) / 3 in + let h = ((19 * a) + b - d - g + 15) mod 30 in + let i = c / 4 and k = c mod 4 in + let l = (32 + (2 * e) + (2 * i) - h - k) mod 7 in + let m = (a + (11 * h) + (22 * l)) / 451 in + let month = (h + l - (7 * m) + 114) / 31 in + let day = ((h + l - (7 * m) + 114) mod 31) + 1 in + mk y month day + +(* Meeus Julian Easter: gives the JULIAN-calendar month/day; convert to the same + physical day expressed in the proleptic Gregorian calendar by adding the + Julian->Gregorian offset (days = y/100 - y/400 - 2). *) +let julian_easter y = + let a = y mod 4 and b = y mod 7 and c = y mod 19 in + let d = ((19 * c) + 15) mod 30 in + let e = ((2 * a) + (4 * b) - d + 34) mod 7 in + let month = (d + e + 114) / 31 in + let day = ((d + e + 114) mod 31) + 1 in + let offset = (y / 100) - (y / 400) - 2 in + Date.of_rata (Date.to_rata (mk y month day) + offset) -- cgit v1.3