summaryrefslogtreecommitdiff
path: root/internal/calendar/calendar.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/calendar/calendar.go')
-rw-r--r--internal/calendar/calendar.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/calendar/calendar.go b/internal/calendar/calendar.go
index d224e87..33706d8 100644
--- a/internal/calendar/calendar.go
+++ b/internal/calendar/calendar.go
@@ -18,6 +18,19 @@ func Compute(date time.Time, sel Selection, layers []Layer) LiturgicalDay {
return computeOF(date, sel, layers)
}
+// TemporalSlug returns the slug of date's TEMPORAL day (the season's Sunday or
+// feria), ignoring any sanctoral celebration that outranks it. The EF's
+// green-season weekday-repeats-the-Sunday rule uses this so a Monday still finds
+// its Sunday Mass even when that Sunday was displaced by a feast (e.g. the
+// Purification on Feb 2).
+func TemporalSlug(date time.Time, sel Selection) string {
+ date = date.UTC().Truncate(24 * time.Hour)
+ if sel.Form == "old" {
+ return temporalEF(date).Cel.Slug
+ }
+ return temporal(date, sel).Cel.Slug
+}
+
// computeEF computes the Extraordinary Form (1962) day.
func computeEF(date time.Time, sel Selection, layers []Layer) LiturgicalDay {
td := temporalEF(date)
@@ -145,10 +158,29 @@ func movableMemorialsOF(y int) []movableCel {
// transferIfImpeded moves a solemnity off a band-1/2 temporal day to the next
// free day. Non-solemnities are never transferred (they yield instead).
+//
+// Two impeded solemnities are ANTICIPATED (moved earlier) rather than deferred,
+// matching the General Roman Calendar's published transfers:
+// - St Joseph (Mar 19) falling in Holy Week goes to the Saturday before Palm
+// Sunday. (The Annunciation, by contrast, defers past the octave via the
+// generic forward walk below -- to the Monday after the 2nd Sunday of Easter.)
+// - The Nativity of St John the Baptist (Jun 24), when the day is a solemnity
+// of the Lord (the Sacred Heart or Corpus Christi falling on Jun 24), goes
+// to Jun 23.
func transferIfImpeded(cel Celebration, when time.Time, sel Selection) time.Time {
if cel.Rank != RankSolemnity {
return when
}
+ if strings.Contains(cel.Slug, "joseph-husband") {
+ if palm := Easter(when.Year()).AddDate(0, 0, -7); !when.Before(palm) {
+ return palm.AddDate(0, 0, -1) // Holy Week -> Saturday before Palm Sunday
+ }
+ }
+ if strings.Contains(cel.Slug, "john-the-baptist") {
+ if td := temporal(when, sel); td.Cel.Rank == RankSolemnity && td.Class == ClassLord && !td.Sunday {
+ return when.AddDate(0, 0, -1) // Sacred Heart / Corpus Christi on Jun 24 -> Jun 23
+ }
+ }
day := when
for i := 0; i < 30; i++ {
b := temporal(day, sel)