blob: a11235d8c55624729348acaf685fba65eddf30e2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package caldata
import (
"time"
"github.com/lukaszkasprzak/lectio/internal/calendar"
)
// Readings resolves a 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). Shared by the CLI (cli.dayReadings
// delegates here) and calfeed.Build (injected as its readings func).
func Readings(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 := 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 TemporalReadings(sel.Form, sd.Observed.Slug)
}
return nil
}
|