aboutsummaryrefslogtreecommitdiff
path: root/internal/caldata/readings.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/caldata/readings.go')
-rw-r--r--internal/caldata/readings.go35
1 files changed, 29 insertions, 6 deletions
diff --git a/internal/caldata/readings.go b/internal/caldata/readings.go
index 2810026..49109f5 100644
--- a/internal/caldata/readings.go
+++ b/internal/caldata/readings.go
@@ -19,14 +19,37 @@ func Readings(sel calendar.Selection, layers []calendar.Layer, date time.Time, d
if len(rs) > 0 {
return rs
}
- // temporal table: EF by slug, OF by slug+cycle.
- key := day.Observed.Slug
- if sel.Form != "old" && day.SundayCycle != "" {
- key = day.Observed.Slug + "-" + day.SundayCycle
+ // temporal table: EF by bare slug; OF by slug+cycle. Sundays & solemnities
+ // use the 3-year Sunday cycle (A/B/C); ferial weekdays use the 2-year
+ // weekday cycle (I/II). Sunday-slugs and weekday-slugs are disjoint, so
+ // trying both cycle suffixes is unambiguous.
+ if sel.Form == "old" {
+ if r := TemporalReadings("old", day.Observed.Slug); len(r) > 0 {
+ return r
+ }
+ } else {
+ for _, cyc := range []string{day.SundayCycle, day.WeekdayCycle} {
+ if cyc == "" {
+ continue
+ }
+ if r := TemporalReadings("new", day.Observed.Slug+"-"+cyc); len(r) > 0 {
+ return r
+ }
+ }
}
- if r := TemporalReadings(sel.Form, key); len(r) > 0 {
- return r
+ // OF: a sanctoral memorial / optional memorial with no proper readings of its
+ // own reads the FERIAL (weekday) readings of the day -- the ordinary OF rule.
+ // Compute the pure temporal (no sanctoral) to get the day's ferial slug.
+ if sel.Form != "old" && day.Observed.Layer != "temporal" &&
+ day.WeekdayCycle != "" && date.Weekday() != time.Sunday {
+ temp := calendar.Compute(date, sel, nil)
+ if temp.Observed.Layer == "temporal" {
+ if r := TemporalReadings("new", temp.Observed.Slug+"-"+day.WeekdayCycle); len(r) > 0 {
+ return r
+ }
+ }
}
+ // EF: a green-season weekday with no proper Mass repeats the preceding Sunday.
if sel.Form == "old" && day.Observed.Layer == "temporal" && date.Weekday() != time.Sunday {
sun := date.AddDate(0, 0, -int(date.Weekday())) // preceding Sunday (Sunday = 0)
sd := calendar.Compute(sun, sel, layers)