aboutsummaryrefslogtreecommitdiff
path: root/internal/calendar/temporal.go
diff options
context:
space:
mode:
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 {