aboutsummaryrefslogtreecommitdiff
path: root/internal/cli/liturgy.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli/liturgy.go')
-rw-r--r--internal/cli/liturgy.go37
1 files changed, 26 insertions, 11 deletions
diff --git a/internal/cli/liturgy.go b/internal/cli/liturgy.go
index 975917a..af58a34 100644
--- a/internal/cli/liturgy.go
+++ b/internal/cli/liturgy.go
@@ -32,10 +32,34 @@ func runLiturgy(cfg config.Config, date string, stdout, stderr io.Writer) int {
}
day := calendar.Compute(d.UTC(), cfg.Selection(), layers)
tbl, _ := bible.LoadBookTable(userBooksINI())
- printLiturgicalDay(stdout, cfg, tbl, day)
+ readings := dayReadings(cfg.Selection(), layers, d.UTC(), day)
+ printLiturgicalDay(stdout, cfg, tbl, day, readings)
return 0
}
+// dayReadings resolves the day's Mass readings: the observed celebration's
+// inline propers, else the temporal lectionary for its slug, else -- for an EF
+// weekday with no proper Mass -- the preceding Sunday's Mass (the 1962 rule
+// that green-season ferias repeat the Sunday).
+func dayReadings(sel calendar.Selection, layers []calendar.Layer, date time.Time, day calendar.LiturgicalDay) []calendar.Reading {
+ var rs []calendar.Reading
+ for _, m := range day.Observed.Masses {
+ rs = append(rs, m.Readings...)
+ }
+ if len(rs) > 0 {
+ return rs
+ }
+ if r := caldata.TemporalReadings(sel.Form, day.Observed.Slug); len(r) > 0 {
+ return r
+ }
+ 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)
+ return caldata.TemporalReadings(sel.Form, sd.Observed.Slug)
+ }
+ return nil
+}
+
// vernacularVersion is the offline corpus used to render reading text: Wujek
// for Polish, Douay-Rheims otherwise (bt is scraped, so it is not used here).
func vernacularVersion(cfg config.Config) string {
@@ -64,7 +88,7 @@ func readingLine(tbl *bible.BookTable, cfg config.Config, version, citation stri
return display, strings.Join(parts, " ")
}
-func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable, day calendar.LiturgicalDay) {
+func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable, day calendar.LiturgicalDay, readings []calendar.Reading) {
fmt.Fprintf(out, "%s %s\n", day.Date.Format("2006-01-02"), day.Weekday.String())
if day.SundayCycle != "" { // OF carries the reading cycles; EF does not
fmt.Fprintf(out, "season: %s (week %d · Sunday cycle %s · weekday cycle %s)\n",
@@ -78,15 +102,6 @@ func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable,
fmt.Fprintf(out, " also: %s [%s]\n", n, rankLabel(o.Rank))
}
}
- // Readings: the observed celebration's inline propers, else the temporal
- // lectionary for the day (proper-of-feast overrides the temporal cycle).
- var readings []calendar.Reading
- for _, m := range day.Observed.Masses {
- readings = append(readings, m.Readings...)
- }
- if len(readings) == 0 {
- readings = caldata.TemporalReadings(cfg.Selection().Form, day.Observed.Slug)
- }
vern := vernacularVersion(cfg)
for _, r := range readings {
disp, txt := readingLine(tbl, cfg, vern, r.Citation)