From a80e61963756a28a3963a0442a8ccc1572518373 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 14:35:24 +0200 Subject: fix(calendar): OF precedence/transfer + readings resolution; EF Pentecost octave Fixes found by validating the offline engine per-day vs the LiturgicalCalendar API (OF) and missalemeum (EF) across 2005-2050. OF calendar is now 0 real errors in the forward window (season/cycle already perfect). OF precedence/transfer (calendar): - Ash Wednesday and Holy Week Mon-Wed are band-2 privileged, so a coinciding feast (Chair of St Peter on Ash Wednesday) is suppressed, not observed. - Solemnities transfer out of Holy Week / the Easter octave: the Annunciation defers to the Monday after the 2nd Sunday of Easter; St Joseph is anticipated to the Saturday before Palm Sunday; the Nativity of St John the Baptist moves to Jun 23 when a Lord's solemnity (Sacred Heart / Corpus Christi) falls Jun 24. - Within a precedence band, a solemnity of the Lord/BVM outranks a saint's (dignity tiebreak) rather than losing an alphabetical slug tie. - Perpetua & Felicity corrected optional -> obligatory memorial. OF readings resolution (bible.OFRef + lectionary data): - Verse-accurate Hebrew->Vulgate psalm mapping incl. the split psalms (9/10, 114/115, 116, 147); "+" verse joins and abbreviated ranges ("127-28") normalized; single-chapter books (2/3 John, Jude) get chapter 1. - Cleaned harvest artifacts from of-lectionary.ini (descriptive-suffix gospels, "or Year A" alternates, "*"/"[Vulg.]"/bracket markers, slash abbreviations); Joel/Malachi/Zechariah/Esther book-versification citations fixed to Vulgate. - Split a merged Ps 15:10/11 row in vul.tsv. Result: 0 unresolvable OF readings over 2557 rendered days (cycles A/B/C, varied Easters). EF: the Octave of Pentecost (Whit Monday-Saturday) is red, not white. --- internal/calendar/calendar.go | 19 +++++++++++++++++++ internal/calendar/precedence.go | 21 +++++++++++++++++++++ internal/calendar/temporal.go | 20 +++++++++++++++++--- internal/calendar/temporal_ef.go | 5 +++++ 4 files changed, 62 insertions(+), 3 deletions(-) (limited to 'internal/calendar') diff --git a/internal/calendar/calendar.go b/internal/calendar/calendar.go index d224e87..9f24caf 100644 --- a/internal/calendar/calendar.go +++ b/internal/calendar/calendar.go @@ -145,10 +145,29 @@ func movableMemorialsOF(y int) []movableCel { // transferIfImpeded moves a solemnity off a band-1/2 temporal day to the next // free day. Non-solemnities are never transferred (they yield instead). +// +// Two impeded solemnities are ANTICIPATED (moved earlier) rather than deferred, +// matching the General Roman Calendar's published transfers: +// - St Joseph (Mar 19) falling in Holy Week goes to the Saturday before Palm +// Sunday. (The Annunciation, by contrast, defers past the octave via the +// generic forward walk below -- to the Monday after the 2nd Sunday of Easter.) +// - The Nativity of St John the Baptist (Jun 24), when the day is a solemnity +// of the Lord (the Sacred Heart or Corpus Christi falling on Jun 24), goes +// to Jun 23. func transferIfImpeded(cel Celebration, when time.Time, sel Selection) time.Time { if cel.Rank != RankSolemnity { return when } + if strings.Contains(cel.Slug, "joseph-husband") { + if palm := Easter(when.Year()).AddDate(0, 0, -7); !when.Before(palm) { + return palm.AddDate(0, 0, -1) // Holy Week -> Saturday before Palm Sunday + } + } + if strings.Contains(cel.Slug, "john-the-baptist") { + if td := temporal(when, sel); td.Cel.Rank == RankSolemnity && td.Class == ClassLord && !td.Sunday { + return when.AddDate(0, 0, -1) // Sacred Heart / Corpus Christi on Jun 24 -> Jun 23 + } + } day := when for i := 0; i < 30; i++ { b := temporal(day, sel) diff --git a/internal/calendar/precedence.go b/internal/calendar/precedence.go index 3b7c0a6..3c7bf5f 100644 --- a/internal/calendar/precedence.go +++ b/internal/calendar/precedence.go @@ -82,6 +82,13 @@ func pick(cands []candidate) (candidate, []candidate) { if pi != pj { return pi < pj } + // Within a band, higher liturgical dignity wins (Table of Liturgical Days: + // of the Lord, then of the BVM, then of saints) -- so a Lord's solemnity + // (Sacred Heart, Corpus Christi) outranks a coinciding saint's solemnity + // rather than losing an alphabetical tie. + if di, dj := dignity(sorted[i].Cel), dignity(sorted[j].Cel); di != dj { + return di < dj + } return sorted[i].Cel.Slug < sorted[j].Cel.Slug }) // General Norms 60: when two obligatory memorials fall on the same day, both @@ -108,6 +115,20 @@ func pick(cands []candidate) (candidate, []candidate) { return sorted[0], sorted[1:] } +// dignity ranks a celebration within its precedence band by the Table of +// Liturgical Days' order of dignity: of the Lord (0), of the BVM (1), of saints +// or unclassified (2). +func dignity(c Celebration) int { + switch c.Class { + case ClassLord: + return 0 + case ClassBVM: + return 1 + default: + return 2 + } +} + // slugIndex returns the position of the candidate with the given slug, or -1. func slugIndex(cands []candidate, slug string) int { for i, c := range cands { diff --git a/internal/calendar/temporal.go b/internal/calendar/temporal.go index b0dc653..1c8d74f 100644 --- a/internal/calendar/temporal.go +++ b/internal/calendar/temporal.go @@ -117,6 +117,15 @@ func ferialDay(season Season, slug string, col Colour, week int, privFeria bool) Cel: Celebration{Slug: slug, Rank: RankFerial, Colour: col, Layer: "temporal"}} } +// privFerialDay builds a band-2 privileged weekday (Ash Wednesday, Holy Week +// Monday-Wednesday): a ferial no sanctoral feast or memorial can displace (only +// a solemnity may, and solemnities transfer off it -- Table of Liturgical Days +// #2). Distinct from ferialDay's PrivFeria (band 9) Lenten/Advent weekdays. +func privFerialDay(season Season, slug string, col Colour, week int) temporalDay { + return temporalDay{Season: season, Colour: col, Week: week, Rank: RankFerial, Privileged: true, + Cel: Celebration{Slug: slug, Rank: RankFerial, Colour: col, Layer: "temporal"}} +} + // temporal computes the temporal identity of date under the given Selection. func temporal(date time.Time, sel Selection) temporalDay { date = date.UTC().Truncate(24 * time.Hour) @@ -180,11 +189,16 @@ func temporal(date time.Time, sel Selection) temporalDay { if sun { return sundayDay(Lent, "palm-sunday", Red, 6) } - return ferialDay(Lent, "holy-week-"+weekdayAbbr(wd), Violet, 6, true) + // Holy Week Mon-Wed are band-2 privileged: no feast/memorial is kept. + return privFerialDay(Lent, "holy-week-"+weekdayAbbr(wd), Violet, 6) case !date.Before(ashWed) && date.Before(palmSunday): // Lent - if !date.Before(ashWed) && date.Before(ashWed.AddDate(0, 0, 4)) { - // Ash Wednesday through the Saturday after (before Lent I). + if sameDay(date, ashWed) { + // Ash Wednesday is band-2 privileged (suppresses any coinciding feast). + return privFerialDay(Lent, "lent-after-ashes-wed", Violet, 0) + } + if date.Before(ashWed.AddDate(0, 0, 4)) { + // Thursday-Saturday after Ash Wednesday (before Lent I): band-9 privileged. return ferialDay(Lent, "lent-after-ashes-"+weekdayAbbr(wd), Violet, 0, true) } lent1 := nextWeekday(ashWed, time.Sunday) diff --git a/internal/calendar/temporal_ef.go b/internal/calendar/temporal_ef.go index 877545c..9e7e7b2 100644 --- a/internal/calendar/temporal_ef.go +++ b/internal/calendar/temporal_ef.go @@ -82,6 +82,11 @@ func temporalEF(date time.Time) temporalDay { easter := Easter(y) season := efSeason(date, y, easter) col := efColour(season) + // The Octave of Pentecost (Whit Monday through the Ember Saturday, easter+50 + // to +55) is red, not the white of the rest of Paschaltide. + if !date.Before(easter.AddDate(0, 0, 50)) && !date.After(easter.AddDate(0, 0, 55)) { + col = Red + } sun := date.Weekday() == time.Sunday // Major feasts of the Lord (I class): nice titles + colour. -- cgit v1.3 From cf45e9f7f3146bca6039b63e2be02463b02f8043 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 14:46:17 +0200 Subject: fix(EF): fill reading gaps (major feasts, feria-repeat-through-feast, sundays) EF readings had ~1.8% of days with no readings (major feasts falling back to the wrong Sunday, feria-repeats broken when the preceding Sunday was a feast). Now 0 gaps over 9496 days (2025-2050); reading correctness spot-checks match missalemeum except the resumed-Epiphany-Sunday edge (next commit). - calendar.TemporalSlug: the green-season weekday-repeats-the-Sunday rule uses the Sunday's TEMPORAL slug, so a Monday still finds its Sunday Mass when that Sunday was displaced by a feast (e.g. the Purification on Feb 2). - Add the missing EF temporal Masses (from missalemeum): the Nativity Day Mass (Heb 1:1-12 / John 1:1-14), Epiphany (Isa 60:1-6 / Matt 2:1-12), the Octave Day of Christmas (Titus 2:11-15 / Luke 2:21), the 6th Sunday after Epiphany (1 Thess 1:2-10 / Matt 13:31-35), and the last Sunday after Pentecost (Col 1:9-14 / Matt 24:15-35). --- internal/caldata/readings.go | 7 ++++--- internal/caldata/tridentine-lectionary.ini | 20 ++++++++++++++++++++ internal/calendar/calendar.go | 13 +++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) (limited to 'internal/calendar') diff --git a/internal/caldata/readings.go b/internal/caldata/readings.go index 1b87b7a..3e46ccd 100644 --- a/internal/caldata/readings.go +++ b/internal/caldata/readings.go @@ -76,11 +76,12 @@ func Readings(sel calendar.Selection, layers []calendar.Layer, date time.Time, d return r } } - // EF: a green-season weekday with no proper Mass repeats the preceding Sunday. + // EF: a green-season weekday with no proper Mass repeats the preceding + // Sunday's Mass. Use the Sunday's TEMPORAL slug (not its observed) so the + // repeat still resolves when that Sunday was a feast (e.g. the Purification). 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 TemporalReadings(sel.Form, calendar.TemporalSlug(sun, sel)) } return nil } diff --git a/internal/caldata/tridentine-lectionary.ini b/internal/caldata/tridentine-lectionary.ini index cef3f2d..52ac060 100644 --- a/internal/caldata/tridentine-lectionary.ini +++ b/internal/caldata/tridentine-lectionary.ini @@ -472,3 +472,23 @@ gospel = Luke 19:41-47 [ef-trinity] first = Rom 11:33-36. gospel = Matt 28:18-20 + +[ef-nativity] +first = Heb 1:1-12 +gospel = John 1:1-14 + +[ef-epiphany] +first = Isa 60:1-6 +gospel = Matt 2:1-12 + +[ef-circumcision] +first = Titus 2:11-15 +gospel = Luke 2:21 + +[ef-time-after-epiphany-sunday-6] +first = 1 Thess 1:2-10 +gospel = Matt 13:31-35 + +[ef-time-after-pentecost-sunday-28] +first = Col 1:9-14 +gospel = Matt 24:15-35 diff --git a/internal/calendar/calendar.go b/internal/calendar/calendar.go index 9f24caf..33706d8 100644 --- a/internal/calendar/calendar.go +++ b/internal/calendar/calendar.go @@ -18,6 +18,19 @@ func Compute(date time.Time, sel Selection, layers []Layer) LiturgicalDay { return computeOF(date, sel, layers) } +// TemporalSlug returns the slug of date's TEMPORAL day (the season's Sunday or +// feria), ignoring any sanctoral celebration that outranks it. The EF's +// green-season weekday-repeats-the-Sunday rule uses this so a Monday still finds +// its Sunday Mass even when that Sunday was displaced by a feast (e.g. the +// Purification on Feb 2). +func TemporalSlug(date time.Time, sel Selection) string { + date = date.UTC().Truncate(24 * time.Hour) + if sel.Form == "old" { + return temporalEF(date).Cel.Slug + } + return temporal(date, sel).Cel.Slug +} + // computeEF computes the Extraordinary Form (1962) day. func computeEF(date time.Time, sel Selection, layers []Layer) LiturgicalDay { td := temporalEF(date) -- cgit v1.3 From c5abf87fa7198c8f245f407774e2326e4b6c9b9c Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 14:54:10 +0200 Subject: fix(EF): resumed Sundays after Pentecost use the Epiphany Masses In early-Easter years there are more than 24 Sundays after Pentecost. Per the 1960 Rubrics the surplus Sundays resume the Sundays after Epiphany that Septuagesima cut short (highest-numbered first) and the last Sunday keeps the 24th (Last) Mass. temporalEF now routes those Sundays to the resumed Epiphany slug for readings while keeping the calendrical time-after-pentecost season; the mis-harvested tail entries (post-Pentecost sundays 24-28) are corrected to the true 24th Mass and the surplus removed. Validated: 88/88 tail/resumed Sunday gospels match missalemeum 2025-2050; EF oracle green. --- internal/caldata/tridentine-lectionary.ini | 16 ++-------------- internal/calendar/temporal_ef.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'internal/calendar') diff --git a/internal/caldata/tridentine-lectionary.ini b/internal/caldata/tridentine-lectionary.ini index 52ac060..06ad9fd 100644 --- a/internal/caldata/tridentine-lectionary.ini +++ b/internal/caldata/tridentine-lectionary.ini @@ -426,20 +426,11 @@ first = Phil 3:17-21; 4:1-3 gospel = Matt 9:18-26 [ef-time-after-pentecost-sunday-24] -first = Rom 13:8-10 -gospel = Matt 8:23-27 +first = Col 1:9-14 +gospel = Matt 24:15-35 -[ef-time-after-pentecost-sunday-25] -first = Col 3:12-17 -gospel = Matt 13:24-30 -[ef-time-after-pentecost-sunday-26] -first = 1 Thess. 1:2-10 -gospel = Matt 13:31-35 -[ef-time-after-pentecost-sunday-27] -first = Col 1:9-14 -gospel = Matt 24:15-35 [ef-time-after-pentecost-sunday-3] first = 1 Pet. 5:6-11 @@ -489,6 +480,3 @@ gospel = Luke 2:21 first = 1 Thess 1:2-10 gospel = Matt 13:31-35 -[ef-time-after-pentecost-sunday-28] -first = Col 1:9-14 -gospel = Matt 24:15-35 diff --git a/internal/calendar/temporal_ef.go b/internal/calendar/temporal_ef.go index 9e7e7b2..7420ebd 100644 --- a/internal/calendar/temporal_ef.go +++ b/internal/calendar/temporal_ef.go @@ -132,6 +132,24 @@ func temporalEF(date time.Time) temporalDay { if season == Advent && sameDay(date, adventStart(y)) { rank = RankClass1 // 1st Sunday of Advent } + // Resumed Sundays after Pentecost (1960 Rubrics): when Easter is early + // there are more than 24 Sundays after Pentecost. The LAST Sunday before + // Advent always keeps the 24th (Last) Mass; the surplus Sundays between the + // 23rd and the last resume the Sundays after Epiphany that Septuagesima cut + // short -- the highest-numbered ones, so the 6th sits just before the Last. + if season == TimeAfterPentecost { + lastSun := adventStart(y).AddDate(0, 0, -7) + if sameDay(date, lastSun) { + return efCel(TimeAfterPentecost, "ef-time-after-pentecost-sunday-24", col, rank, 24) + } + if week > 23 { + p := daysBetween(easter.AddDate(0, 0, 49), lastSun) / 7 // total Sundays after Pentecost + e := week - p + 7 // resumed Sunday after Epiphany + // Season stays time-after-pentecost (calendrical); the Epiphany + // slug only routes the readings to the resumed Mass. + return efCel(TimeAfterPentecost, "ef-time-after-epiphany-sunday-"+strconv.Itoa(e), Green, rank, e) + } + } return efCel(season, "ef-"+string(season)+"-sunday-"+strconv.Itoa(week), col, rank, week) } // The days between Ash Wednesday and the 1st Sunday of Lent have their own -- cgit v1.3