aboutsummaryrefslogtreecommitdiff
path: root/internal/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'internal/calendar')
-rw-r--r--internal/calendar/coverage_test.go19
-rw-r--r--internal/calendar/temporal.go9
2 files changed, 26 insertions, 2 deletions
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