diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 14:02:49 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 14:02:49 +0200 |
| commit | 78825639eab3c84d84a60fbd1f1781bcfa332044 (patch) | |
| tree | 75135a3e67d263a048470198e12e4573dc59e63a /internal/caldata/caldata.go | |
| parent | 58b748340059a02e696f6a7168f81114ac0f99e9 (diff) | |
| download | lectio-78825639eab3c84d84a60fbd1f1781bcfa332044.tar.gz lectio-78825639eab3c84d84a60fbd1f1781bcfa332044.zip | |
feat(caldata,cli): embed 1962 EF calendar + form-aware Stack; --liturgy computes EF
caldata.Tridentine()/Base(form); Stack(form,dir,use); runLiturgy drops the EF
guard and uses the form's base; rankLabel shows I-IV class; display omits OF
cycles + strips ef- slug prefix for EF.
Diffstat (limited to 'internal/caldata/caldata.go')
| -rw-r--r-- | internal/caldata/caldata.go | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/internal/caldata/caldata.go b/internal/caldata/caldata.go index 9272fbb..14b3985 100644 --- a/internal/caldata/caldata.go +++ b/internal/caldata/caldata.go @@ -16,8 +16,11 @@ import ( //go:embed roman-calendar.ini var romanCalendar []byte -// Universal parses the embedded universal calendar. It panics on a malformed -// embedded file (a build-time bug caught by tests), never at the request layer. +//go:embed tridentine-calendar.ini +var tridentineCalendar []byte + +// 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 { l, err := ParseLayer(romanCalendar) if err != nil { @@ -26,6 +29,24 @@ func Universal() calendar.Layer { return l } +// Tridentine parses the embedded Extraordinary Form (1962) universal calendar. +func Tridentine() calendar.Layer { + l, err := ParseLayer(tridentineCalendar) + if err != nil { + panic(fmt.Sprintf("caldata: embedded tridentine-calendar.ini invalid: %v", err)) + } + return l +} + +// Base returns the universal base layer for a form: the 1962 calendar for +// "old" (EF), the General Roman Calendar otherwise (OF). +func Base(form string) calendar.Layer { + if form == "old" { + return Tridentine() + } + return Universal() +} + // LoadLayer reads and parses a user calendar layer file. id (the filename stem) // is used as the layer's ID when the file's [layer] header omits one. func LoadLayer(path, id string) (calendar.Layer, error) { @@ -43,12 +64,12 @@ func LoadLayer(path, id string) (calendar.Layer, error) { return l, nil } -// Stack returns the ordered layer stack for the engine: the universal base -// first, then each user layer named in use (matched to "<dir>/<id>.ini"), in -// order. A layer that fails to load is skipped and reported in the error slice -// so a single bad file never breaks calendar computation. -func Stack(dir string, use []string) ([]calendar.Layer, []error) { - layers := []calendar.Layer{Universal()} +// Stack returns the ordered layer stack for the engine: the form's universal +// base first, then each user layer named in use (matched to "<dir>/<id>.ini"), +// in order. A layer that fails to load is skipped and reported in the error +// slice so a single bad file never breaks calendar computation. +func Stack(form, dir string, use []string) ([]calendar.Layer, []error) { + layers := []calendar.Layer{Base(form)} var errs []error for _, id := range use { l, err := LoadLayer(filepath.Join(dir, id+".ini"), id) |
