calendar: move Sunday-governance arithmetic from day-label.ts into temporal.ts
Deploy / deploy (push) Successful in 37s
Deploy / deploy (push) Successful in 37s
sundayOnOrBefore and firstSundayStrictlyAfter are calendar facts ("which
Sunday does this feria belong to"), not presentation logic — day-label.ts
was the only consumer so far, but a future temporal-propers content
resolver (PropersRef's still-unused source: 'temporal' branch) will need
the exact same arithmetic, just keyed for content ids instead of display
strings. Moving it now, while the shape is still small and well
understood, rather than duplicating it later.
day-label.ts keeps the actual display config (which anchor, "Trinity" vs
"Pentecost" wording) — that part stays presentation-only on purpose, since
it's also where a future counting-convention setting would hook in.
No behavior change: 88/88 tests still pass.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
// forever — just not built yet.
|
||||
import type { LiturgicalDay } from './types';
|
||||
import { easterSunday } from './easter';
|
||||
import { adventStart } from './temporal';
|
||||
import { adventStart, firstSundayStrictlyAfter, sundayOnOrBefore } from './temporal';
|
||||
import { addDays, daysBetween, toIsoDate } from './date-math';
|
||||
|
||||
function capitalize(text: string): string {
|
||||
@@ -35,20 +35,6 @@ function ordinal(n: number): string {
|
||||
}
|
||||
}
|
||||
|
||||
function weekdayOf(isoDate: string): number {
|
||||
return new Date(`${isoDate}T00:00:00Z`).getUTCDay(); // 0 = Sunday
|
||||
}
|
||||
|
||||
/** The first Sunday strictly after `isoDate` (even if `isoDate` is itself a Sunday). */
|
||||
function firstSundayStrictlyAfter(isoDate: string): string {
|
||||
const dow = weekdayOf(isoDate);
|
||||
return addDays(isoDate, dow === 0 ? 7 : 7 - dow);
|
||||
}
|
||||
|
||||
function sundayOnOrBefore(isoDate: string): string {
|
||||
return addDays(isoDate, -weekdayOf(isoDate));
|
||||
}
|
||||
|
||||
interface OrdinalSeason {
|
||||
/** ISO date of the season's own anchor day, for a given calendar year. */
|
||||
anchorDate(year: number): string;
|
||||
|
||||
Reference in New Issue
Block a user