aboutsummaryrefslogtreecommitdiff
path: root/internal/calendar/temporal.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 12:33:47 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 12:33:47 +0200
commitf5afb407beab795e371c36a3229e991e48c366fe (patch)
treeb9378cca00e46a1b063d53f3cfa52546ae782f9f /internal/calendar/temporal.go
parent56f3b8161f73c33fe6e25f6461d3f061af427e9e (diff)
downloadlectio-f5afb407beab795e371c36a3229e991e48c366fe.tar.gz
lectio-f5afb407beab795e371c36a3229e991e48c366fe.zip
test(calendar): regression oracle vs calapi 2020-2040 (0 season mismatches)
Caught + fixed an Advent-start bug: anchor on Christmas Eve, not Dec 25, so years where Dec 25 is a Sunday don't lose the first week of Advent. Rank-class diffs (324) are informational — the initial sanctoral dataset is partial.
Diffstat (limited to 'internal/calendar/temporal.go')
-rw-r--r--internal/calendar/temporal.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/calendar/temporal.go b/internal/calendar/temporal.go
index 568efdc..b14e974 100644
--- a/internal/calendar/temporal.go
+++ b/internal/calendar/temporal.go
@@ -23,11 +23,15 @@ type temporalDay struct {
}
// adventStart returns the First Sunday of Advent that opens the liturgical year
-// containing Christmas of the given calendar year: the 4th Sunday before Dec 25.
+// containing Christmas of the given calendar year. The 4th Sunday of Advent is
+// the Sunday on or before Christmas Eve (Dec 24) — anchoring on Dec 24, not
+// Dec 25, keeps Christmas Day itself from being counted as an Advent Sunday
+// (which loses a week in years when Dec 25 is a Sunday). Advent I is 3 Sundays
+// earlier.
func adventStart(year int) time.Time {
- xmas := time.Date(year, 12, 25, 0, 0, 0, 0, time.UTC)
- sun := xmas.AddDate(0, 0, -int(xmas.Weekday())) // Sunday on/before Christmas (Sunday=0)
- return sun.AddDate(0, 0, -21)
+ eve := time.Date(year, 12, 24, 0, 0, 0, 0, time.UTC)
+ sun := eve.AddDate(0, 0, -int(eve.Weekday())) // 4th Sunday of Advent
+ return sun.AddDate(0, 0, -21) // 1st Sunday of Advent
}
func sameDay(a, b time.Time) bool {