From 6641ce335de522e6d51c47ad9d14f69726650592 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 09:30:22 +0200 Subject: fix(of): canonical OT ferial week numbering + CR-sourced ferial lectionary The Ordinary Form ferial lectionary had two linked defects, both from harvesting niedziela.pl by date: (1) post-Pentecost Ordinary-Time ferial WEEK NUMBERS were one too high (temporal.go counted back from Christ the King using the weekday itself, not its preceding Sunday, so a ferial took the next week's number), and (2) ~17 ferial keys held a SAINT's readings (stored when a saint displaced the ferial on the queried date, e.g. week 22 smeared with a Marian Prov 8/John 2), plus 16 weekday slots were missing entirely. - temporal.go: number a span-2 ferial from its preceding Sunday. Verified 388/388 ferial-week agreement with calapi across 2026-2028. - scripts/genlect-of-cr.py: regenerate the Ordinary-Time ferial lectionary (first/psalm/gospel, both years, all 34 weeks) from catholic-resources.org (Fr. Felix Just, S.J.), which is keyed by liturgical position (immune to by-date contamination) and complete. Citations only; text still rendered from the public-domain corpora. of-lectionary.ini OT ferials now 408 (was 392). Fixes ~17 contaminated entries + 16 gaps + the week-numbering audit item. Psalms already share modern numbering, so no conversion. Adds TestOFOrdinaryTimeFerialWeek. Credits catholic-resources.org in NOTICE. Bumps to 0.40.0. --- internal/calendar/coverage_test.go | 19 +++++++++++++++++++ internal/calendar/temporal.go | 9 +++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'internal/calendar') diff --git a/internal/calendar/coverage_test.go b/internal/calendar/coverage_test.go index e6555b9..cbd3fde 100644 --- a/internal/calendar/coverage_test.go +++ b/internal/calendar/coverage_test.go @@ -52,6 +52,25 @@ func TestEFCoverage(t *testing.T) { } } +// TestOFOrdinaryTimeFerialWeek guards the post-Pentecost Ordinary-Time ferial +// week numbering, which was one too high (a weekday took Christ-the-King's week +// instead of its preceding Sunday's). calapi confirms these canonical weeks. +func TestOFOrdinaryTimeFerialWeek(t *testing.T) { + sel := calendar.DefaultSelection() + layers := []calendar.Layer{caldata.Universal()} + for _, c := range []struct { + date time.Time + slug string + }{ + {day(2026, time.June, 8), "ordinary-10-mon"}, // calapi: 10th week + {day(2026, time.June, 15), "ordinary-11-mon"}, // calapi: 11th week + } { + if got := calendar.Compute(c.date, sel, layers); got.Observed.Slug != c.slug { + t.Errorf("%s: OT ferial slug %q, want %q", c.date.Format("2006-01-02"), got.Observed.Slug, c.slug) + } + } +} + // TestOFMovableMemorials checks Mary, Mother of the Church, the Immaculate Heart, // and the two-obligatory-memorials rule. func TestOFMovableMemorials(t *testing.T) { diff --git a/internal/calendar/temporal.go b/internal/calendar/temporal.go index 13f1385..ab1a742 100644 --- a/internal/calendar/temporal.go +++ b/internal/calendar/temporal.go @@ -231,8 +231,13 @@ func temporal(date time.Time, sel Selection) temporalDay { if date.Before(ashWed) { week = daysBetween(baptismThis, date)/7 + 1 } else { - // count back from Christ the King = the 34th week. - week = 34 - daysBetween(date, christTheKing)/7 + // Span 2 resumes after Pentecost; Sundays are numbered backward from + // Christ the King (the 34th and last Sunday). A weekday takes the number + // of its preceding Sunday, so count from that Sunday, not from the + // weekday itself (which would round toward Christ the King and land a + // week too high — the OT ferial off-by-one). + precedingSunday := date.AddDate(0, 0, -int(date.Weekday())) + week = 34 - daysBetween(precedingSunday, christTheKing)/7 } if week < 1 { week = 1 -- cgit v1.3