diff options
Diffstat (limited to 'internal/readings/readings.go')
| -rw-r--r-- | internal/readings/readings.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/internal/readings/readings.go b/internal/readings/readings.go index ac7209a..047e901 100644 --- a/internal/readings/readings.go +++ b/internal/readings/readings.go @@ -28,29 +28,33 @@ type Options struct { All bool } -// Load fetches the day's sections for the configured lectionary -// (cfg.Lectionary: "traditional" or "new") and applies part filtering. -// Returns liturgy.Section values regardless of source. -func Load(cfg config.Config, opts Options) ([]liturgy.Section, error) { +// Load fetches the day's sections and its DayInfo (celebration name, +// temporal, liturgical colour -- see liturgy.DayInfo) for the configured +// lectionary (cfg.Lectionary: "traditional" or "new") and applies part +// filtering. Returns liturgy.Section values regardless of source. A source +// that yields no DayInfo (see liturgy.Load/tradlit.Load) comes back as a +// zero liturgy.DayInfo, not an error -- callers omit the header for it. +func Load(cfg config.Config, opts Options) ([]liturgy.Section, liturgy.DayInfo, error) { offline := opts.Offline || cfg.Offline var secs []liturgy.Section + var info liturgy.DayInfo var err error if cfg.Lectionary == "traditional" { - secs, err = tradlit.Load(opts.Date, cfg.TraditionalLang, offline) + secs, info, err = tradlit.Load(opts.Date, cfg.TraditionalLang, offline) } else { - secs, err = liturgy.Load(liturgy.Options{ + secs, info, err = liturgy.Load(liturgy.Options{ Date: opts.Date, Refresh: opts.Refresh, Offline: offline, }) } if err != nil { - return nil, err + return nil, liturgy.DayInfo{}, err } - return filterParts(secs, cfg, opts.All), nil + return filterParts(secs, cfg, opts.All), info, nil } // filterParts keeps only the gospel when !all (PartID "ewangelia" modern or |
