aboutsummaryrefslogtreecommitdiff
path: root/internal/caldata/caldata.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/caldata/caldata.go')
-rw-r--r--internal/caldata/caldata.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/caldata/caldata.go b/internal/caldata/caldata.go
index 14b3985..92f9327 100644
--- a/internal/caldata/caldata.go
+++ b/internal/caldata/caldata.go
@@ -19,6 +19,39 @@ var romanCalendar []byte
//go:embed tridentine-calendar.ini
var tridentineCalendar []byte
+//go:embed tridentine-lectionary.ini
+var tridentineLectionary []byte
+
+// efTempReadings maps an EF temporal-day slug to its readings (parsed once).
+var efTempReadings = parseLectionary(tridentineLectionary)
+
+func parseLectionary(data []byte) map[string][]calendar.Reading {
+ l, err := ParseLayer(data)
+ if err != nil {
+ panic(fmt.Sprintf("caldata: tridentine-lectionary.ini invalid: %v", err))
+ }
+ out := map[string][]calendar.Reading{}
+ for slug, rc := range l.Cels {
+ var rs []calendar.Reading
+ for _, part := range []string{"first", "psalm", "second", "gospel"} {
+ if c := rc.Fields[part]; c != "" {
+ rs = append(rs, calendar.Reading{Part: part, Citation: c})
+ }
+ }
+ out[slug] = rs
+ }
+ return out
+}
+
+// TemporalReadings returns the temporal-cycle readings for a computed day slug,
+// or nil. Only the EF ("old") temporal lectionary exists so far.
+func TemporalReadings(form, slug string) []calendar.Reading {
+ if form == "old" {
+ return efTempReadings[slug]
+ }
+ return nil
+}
+
// Universal parses the embedded Ordinary Form universal calendar. It panics on a
// malformed embedded file (a build-time bug caught by tests).
func Universal() calendar.Layer {