diff options
Diffstat (limited to 'internal/calendar/temporal_ef.go')
| -rw-r--r-- | internal/calendar/temporal_ef.go | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/internal/calendar/temporal_ef.go b/internal/calendar/temporal_ef.go index e8630b9..26ad930 100644 --- a/internal/calendar/temporal_ef.go +++ b/internal/calendar/temporal_ef.go @@ -279,6 +279,18 @@ func temporalEF(date time.Time) temporalDay { return efCel(season, "ef-"+string(slugSeason)+"-"+strconv.Itoa(week)+"-"+weekdayLower(date), col, rank, week) } +// firstSundayAfterEpiphany returns the first Sunday strictly after 6 January +// of year y -- the anchor the weeks after Epiphany are numbered from. When +// Epiphany itself falls on a Sunday the next one is meant, which is why the +// loop starts on 7 January rather than on the 6th. +func firstSundayAfterEpiphany(y int) time.Time { + d := time.Date(y, time.January, 7, 0, 0, 0, 0, time.UTC) + for d.Weekday() != time.Sunday { + d = d.AddDate(0, 0, 1) + } + return d +} + // thirdSundayOfSeptember returns the third Sunday in September of year y. func thirdSundayOfSeptember(y int) time.Time { d := time.Date(y, time.September, 1, 0, 0, 0, 0, time.UTC) @@ -348,8 +360,17 @@ func efWeek(date time.Time, season Season, y int, easter time.Time) int { case Lent: return daysBetween(easter.AddDate(0, 0, -42), date)/7 + 1 // from 1st Sunday of Lent case TimeAfterEpiphany: - jan6 := time.Date(y, 1, 6, 0, 0, 0, 0, time.UTC) - return daysBetween(jan6, date)/7 + 1 + // Weeks after Epiphany are numbered from the FIRST SUNDAY after + // Epiphany, not from Epiphany itself. Counting from 6 January put every + // week one too high: 14 January 2026 came out as week 2 when the first + // Sunday after Epiphany was 11 January and the week running from it is + // the first. + // + // The Sunday is the anchor because it is the Sunday that carries the + // Mass the week is named for -- "Dominica I post Epiphaniam" and then + // its ferias. Epiphany itself is a feast inside Christmas Time (RG 72), + // not the head of a numbered week. + return daysBetween(firstSundayAfterEpiphany(y), date)/7 + 1 case Septuagesima: return daysBetween(easter.AddDate(0, 0, -63), date)/7 + 1 case Easter_: |
