aboutsummaryrefslogtreecommitdiff
path: root/internal/calendar/temporal_ef_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/calendar/temporal_ef_test.go')
-rw-r--r--internal/calendar/temporal_ef_test.go54
1 files changed, 53 insertions, 1 deletions
diff --git a/internal/calendar/temporal_ef_test.go b/internal/calendar/temporal_ef_test.go
index 7dd7400..a7fa8b0 100644
--- a/internal/calendar/temporal_ef_test.go
+++ b/internal/calendar/temporal_ef_test.go
@@ -1,6 +1,9 @@
package calendar
-import "testing"
+import (
+ "testing"
+ "time"
+)
func TestTemporalEFSeasons(t *testing.T) {
cases := []struct {
@@ -204,3 +207,52 @@ func TestTemporalEFChristmastideBoundary(t *testing.T) {
}
}
}
+
+// TestTemporalEFEpiphanyWeekAnchor pins where the weeks after Epiphany are
+// counted from. They are numbered from the FIRST SUNDAY after Epiphany, not
+// from Epiphany itself -- the Sunday carries the Mass the week is named for
+// ("Dominica I post Epiphaniam"), while Epiphany is a feast inside Christmas
+// Time (RG 72), not the head of a numbered week.
+//
+// Counting from 6 January put every week one too high, all year until
+// Septuagesima cut the season short.
+func TestTemporalEFEpiphanyWeekAnchor(t *testing.T) {
+ // 2026: Epiphany is a Tuesday, so the first Sunday after it is 11 January.
+ for _, c := range []struct {
+ date string
+ week int
+ }{
+ {"2026-01-14", 1}, // Wednesday of the week running from 11 January
+ {"2026-01-17", 1}, // still that week
+ {"2026-01-20", 2},
+ {"2026-01-27", 3},
+ } {
+ if got := temporalEF(d(c.date)).Week; got != c.week {
+ t.Errorf("%s: week = %d, want %d (weeks after Epiphany count from the "+
+ "first Sunday after it, not from 6 January)", c.date, got, c.week)
+ }
+ }
+ // 2028: Epiphany falls ON a Thursday and 9 January is the Sunday; but the
+ // year that matters for the off-by-one is one where Epiphany is itself a
+ // Sunday, since then "the first Sunday AFTER Epiphany" is the following
+ // week and a naive same-day anchor would be seven days out.
+ y := 0
+ for c := 2005; c <= 2050; c++ {
+ if time.Date(c, time.January, 6, 0, 0, 0, 0, time.UTC).Weekday() == time.Sunday {
+ y = c
+ break
+ }
+ }
+ if y == 0 {
+ t.Fatal("no year in 2005..2050 has Epiphany on a Sunday -- adjust this test")
+ }
+ anchor := firstSundayAfterEpiphany(y)
+ if anchor.Day() == 6 {
+ t.Errorf("%d: Epiphany is a Sunday and the anchor landed on it (%s); the "+
+ "first Sunday AFTER Epiphany is the next one", y, anchor.Format("2006-01-02"))
+ }
+ if got := temporalEF(anchor).Week; got != 1 {
+ t.Errorf("%d: the first Sunday after Epiphany (%s) should be week 1, got %d",
+ y, anchor.Format("2006-01-02"), got)
+ }
+}