[engine] Sun: nextInvitation checks yesterday, today and tomorrow; addDays steps the calendar; NamedPlace

This commit is contained in:
2026-11-02 00:01:50 +01:00
parent fb7171c3a7
commit 1e8d1cda5a
5 changed files with 101 additions and 6 deletions
+8
View File
@@ -61,6 +61,14 @@ export function localDay(epochMs: number, timeZone: string): LocalDay {
return day;
}
/** The calendar day `days` after `day` (before, if negative). A calendar step: no zone, no DST. */
export function addDays(day: LocalDay, days: number): LocalDay {
if (!isLocalDay(day)) throw new RangeError(`addDays: '${day}' is not a LocalDay`);
if (!Number.isInteger(days)) throw new RangeError(`addDays: ${days} is not a whole number of days`);
const [y, m, d] = day.split('-').map(Number) as [number, number, number];
return localDay(Date.UTC(y, m - 1, d + days), 'UTC');
}
/** Whether `value` has the shape of a LocalDay. Does not check that the date exists. */
export function isLocalDay(value: string): value is LocalDay {
return LOCAL_DAY.test(value);