aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-11 14:02:35 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-11 14:02:35 +0200
commit53e0639612a348ddc66e33952d913c5257fe2ba8 (patch)
tree0738d50e5cfbd04057545314ec0dbb5887a50ca5 /lib
parent2baaa9a441aaeb22f6fcab096c74d9bfd82f3188 (diff)
downloadcolitur-53e0639612a348ddc66e33952d913c5257fe2ba8.tar.gz
colitur-53e0639612a348ddc66e33952d913c5257fe2ba8.zip
rite(ef): pin down floor_div and week/sunday_slug agreement
Task 12 review: add a permanent regression test for floor_div's negative branch (Ash Wednesday, 4 days before the Lent I origin -- the only date in the system where it fires), and stop sunday_slug from independently recomputing the Pentecost-relative week number that week already computes. A cross-check test pins the two together before the refactor and continues to guard against future duplication.
Diffstat (limited to 'lib')
-rw-r--r--lib/rites/rite_ef/temporal_ef.ml32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/rites/rite_ef/temporal_ef.ml b/lib/rites/rite_ef/temporal_ef.ml
index 9e8bcc4..6786cd2 100644
--- a/lib/rites/rite_ef/temporal_ef.ml
+++ b/lib/rites/rite_ef/temporal_ef.ml
@@ -165,20 +165,24 @@ let sunday_slug d =
Some "ef-holy-name-sunday"
else None
| Time_after_pentecost -> (
- let easter = Computus.gregorian_easter y in
- let pentecost = Date.add_days easter 49 in
- let last_sunday = Date.add_days (advent_start y) (-7) in
- let n = days_between pentecost d / 7 in
- if same d last_sunday then
- (* The last Sunday before Advent always keeps the 24th (Last) Mass. *)
- Some "ef-time-after-pentecost-sunday-24"
- else if n > 23 then
- (* Surplus Sundays resume the Sundays after Epiphany that Septuagesima
- cut short -- the highest-numbered ones, so the 6th sits just before
- the Last. *)
- let total = days_between pentecost last_sunday / 7 in
- Some (Printf.sprintf "ef-time-after-epiphany-sunday-%d" (n - total + 7))
- else Some (Printf.sprintf "ef-time-after-pentecost-sunday-%d" n))
+ (* Reuse [week] rather than recomputing the Pentecost-relative week
+ number locally, so the two can never drift apart (see
+ test_week_sunday_slug_agree). Only the last Sunday and the resumed
+ tail are genuinely special. *)
+ match week d with
+ | None -> None
+ | Some n ->
+ let last_sunday = Date.add_days (advent_start y) (-7) in
+ if same d last_sunday then
+ (* The last Sunday before Advent always keeps the 24th (Last) Mass. *)
+ Some "ef-time-after-pentecost-sunday-24"
+ else if n > 23 then
+ (* Surplus Sundays resume the Sundays after Epiphany that Septuagesima
+ cut short -- the highest-numbered ones, so the 6th sits just before
+ the Last. *)
+ let total = match week last_sunday with Some t -> t | None -> n in
+ Some (Printf.sprintf "ef-time-after-epiphany-sunday-%d" (n - total + 7))
+ else Some (Printf.sprintf "ef-time-after-pentecost-sunday-%d" n))
| _ -> (
match week d with
| Some n -> Some (Printf.sprintf "ef-%s-sunday-%d" (season_slug_word s) n)