diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 13:54:19 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 13:54:19 +0200 |
| commit | 5d96dd46ae8ed6b4f4cae6a0dd771a33cdc3a317 (patch) | |
| tree | 667f7976de1778c04de393b124d78f165d244ffd | |
| parent | 72f9213bd8532b0527a1585cb3a87e3c9e061e1a (diff) | |
| download | lectio-5d96dd46ae8ed6b4f4cae6a0dd771a33cdc3a317.tar.gz lectio-5d96dd46ae8ed6b4f4cae6a0dd771a33cdc3a317.zip | |
refactor(calendar): Rank int enum -> unified string token (OF unchanged, oracle 0 mismatches)
Adds EF rank constants (class-1..4, commemoration); ofRankOrder() for the two
ordered comparisons; buildCelebration defaults missing rank to ferial.
| -rw-r--r-- | internal/calendar/calendar.go | 7 | ||||
| -rw-r--r-- | internal/calendar/types.go | 40 |
2 files changed, 39 insertions, 8 deletions
diff --git a/internal/calendar/calendar.go b/internal/calendar/calendar.go index 3465182..98dec43 100644 --- a/internal/calendar/calendar.go +++ b/internal/calendar/calendar.go @@ -26,10 +26,10 @@ func Compute(date time.Time, sel Selection, layers []Layer) LiturgicalDay { } // On band-2 privileged days only solemnities survive (and they transfer); // on Sundays (band 6) only feasts and solemnities compete. - if td.Privileged && cel.Rank < RankSolemnity { + if td.Privileged && ofRankOrder(cel.Rank) < ofRankOrder(RankSolemnity) { continue } - if td.Sunday && cel.Rank < RankFeast { + if td.Sunday && ofRankOrder(cel.Rank) < ofRankOrder(RankFeast) { continue } effective := transferIfImpeded(cel, when, sel) @@ -105,6 +105,9 @@ func buildCelebration(slug string, rc RawCelebration) Celebration { c.Name[strings.TrimPrefix(k, "name.")] = v } } + if c.Rank == "" { + c.Rank = RankFerial + } if m := massFrom(rc.Fields); len(m.Readings) > 0 { c.Masses = append(c.Masses, m) } diff --git a/internal/calendar/types.go b/internal/calendar/types.go index 77d57ab..0ccef8b 100644 --- a/internal/calendar/types.go +++ b/internal/calendar/types.go @@ -4,16 +4,44 @@ package calendar import "time" -type Rank int +// Rank is a form-specific rank token. Ordinary Form uses the values below; +// the Extraordinary Form uses its own (class-1..class-4, commemoration, ferial). +// Each form's precedence interprets its own vocabulary. +type Rank string const ( - RankFerial Rank = iota // ordinary weekday - RankOptional // optional memorial - RankMemorial // obligatory memorial - RankFeast - RankSolemnity + // Ordinary Form ranks. + RankFerial Rank = "ferial" // ordinary weekday + RankOptional Rank = "optional" // optional memorial + RankMemorial Rank = "memorial" // obligatory memorial + RankFeast Rank = "feast" // + RankSolemnity Rank = "solemnity" // + + // Extraordinary Form ranks (1960 Code of Rubrics): I-IV class + commemoration. + RankClass1 Rank = "class-1" + RankClass2 Rank = "class-2" + RankClass3 Rank = "class-3" + RankClass4 Rank = "class-4" + RankCommemoration Rank = "commemoration" ) +// ofRankOrder orders the Ordinary Form ranks for the few `<` comparisons in the +// OF path (ferial lowest, solemnity highest). Unknown/empty → 0 (ferial-level). +func ofRankOrder(r Rank) int { + switch r { + case RankSolemnity: + return 4 + case RankFeast: + return 3 + case RankMemorial: + return 2 + case RankOptional: + return 1 + default: + return 0 + } +} + type Class int const ( |
