37ac31c3f2
Deploy / deploy (push) Successful in 39s
Corrects and completes the occurrence rules, based on a design discussion plus one concrete data point: St. Anthony Abbot (plain Duplex) was found outright winning against an ordinary Sunday in the real Monastic 1617 engine, which the old duplex-1-classis-only threshold got wrong. - FeastClass gains `vigil`, inserted between `simplex` and `semiduplex` — one ordering that correctly serves both "does this win against a Sunday" (vigil behaves like simplex there) and "which of two saints wins a landing-day collision" (vigil beats simplex, loses to semiduplex). - LiturgicalDay.occurring (a flat OccurringFeast[] that could only ever express a losing *sanctoral* candidate) is replaced by `winner: DayWinner` + `commemorations: Commemoration[]` — a discriminated list that can hold the temporal day itself, one or more sanctoral entries, or (not built yet, but the shape already accommodates it) a future octave kind. - commemorations.ts: ordinary Sundays let Duplex+ win outright (Sunday commemorated in return), Semiduplex/Vigil transfer elsewhere (too substantial a feast to cheapen with a bare commemoration), Simplex stays and is commemorated. Privileged Sundays never displace; Duplex-majus+ commemorated, everything else transfers. - collision.ts (new): resolves two sanctoral candidates wanting the same day (a transfer landing on an already-occupied day, or two native saints sharing a date) — duplex > semiduplex > vigil > simplex, loser always commemorated, ties favor the native occupant. - temporal-id.ts (new): maps any date to one of the 52 real Sunday-collect ids from the previous commit, so a temporal winner/commemoration can actually be looked up, not just labeled "temporal" in the abstract. - index.ts's resolveDay orchestrates all of it, including the actual Monday/Saturday transfer mechanism. Landing on a privileged feria (the concrete case: Holy Week, right after Palm Sunday) is explicitly deferred rather than guessed at — it needs its own Easter-keyed lookup table, the same way the reference engine handles it. Added the Vigil of St. Lawrence (Aug 9) as real content specifically to exercise the backward-transfer rule end-to-end: Aug 9, 2026 is a Sunday, so the vigil transfers cleanly back to Saturday, verified by a new integration test alongside the unit-level rule and collision tests.
52 lines
2.4 KiB
TypeScript
52 lines
2.4 KiB
TypeScript
import type { LiturgicalDay } from '../calendar/types';
|
|
import { easterSunday } from '../calendar/easter';
|
|
import { addDays, toIsoDate } from '../calendar/date-math';
|
|
import { resolveSeasonalPropersId } from './seasonal-propers';
|
|
import bySeasonData from '../data/hours/marian-antiphon-by-season.yml';
|
|
|
|
const bySeason = bySeasonData as { perAnnum: string; bySeason: Record<string, string> };
|
|
|
|
const AVE_REGINA_CAELORUM_ID = 'marian-antiphon-ave-regina-caelorum';
|
|
|
|
/**
|
|
* Ave Regina Caelorum's real window (Candlemas through Wednesday of Holy
|
|
* Week) doesn't line up with any of the mutually-exclusive `season` values
|
|
* the rest of the app uses (it starts mid-Epiphanytide and ends mid-Lent
|
|
* or mid-Passiontide, depending on the year) — see calendar/types.ts's
|
|
* Season doc comment for the general overlapping-windows problem this is
|
|
* one instance of. Rather than force `season` to represent it, this checks
|
|
* the real date directly, bypassing the by-season table for this one case.
|
|
* The Triduum (Maundy Thursday through Holy Saturday) that follows isn't
|
|
* specially handled — it falls through to whatever `season` resolves to
|
|
* there (currently 'passiontide', not a key in marian-antiphon-by-season's
|
|
* bySeason table, so it lands on the perAnnum default), which is a known,
|
|
* separate gap, not something this fix claims to solve.
|
|
*/
|
|
function isCandlemasToHolyWednesday(isoDate: string): boolean {
|
|
const year = Number(isoDate.slice(0, 4));
|
|
const candlemas = `${year}-02-02`;
|
|
const maundyThursday = addDays(toIsoDate(easterSunday(year)), -3);
|
|
return isoDate >= candlemas && isoDate < maundyThursday;
|
|
}
|
|
|
|
/** Resolves the common-propers id for Compline's closing Marian antiphon. */
|
|
export function getMarianAntiphonId(day: LiturgicalDay): string {
|
|
if (isCandlemasToHolyWednesday(day.date)) {
|
|
return AVE_REGINA_CAELORUM_ID;
|
|
}
|
|
return resolveSeasonalPropersId(day.season, day.winner, bySeason);
|
|
}
|
|
|
|
const LABELS: Record<string, string> = {
|
|
'marian-antiphon-alma-redemptoris-advent': 'Alma Redemptoris Mater',
|
|
'marian-antiphon-alma-redemptoris-nativity': 'Alma Redemptoris Mater',
|
|
'marian-antiphon-ave-regina-caelorum': 'Ave Regina Caelorum',
|
|
'marian-antiphon-regina-caeli': 'Regina Caeli',
|
|
'marian-antiphon-salve-regina': 'Salve Regina',
|
|
};
|
|
|
|
/** The real, singable name of whichever antiphon getMarianAntiphonId picked. */
|
|
export function getMarianAntiphonLabel(id: string): string {
|
|
return LABELS[id] ?? 'Marian Antiphon';
|
|
}
|