// The Christmas season of the gift campaign (Budapest dates; the backend // marks the gifts by the same window). const parts = (now: Date) => { const [y, m, d] = new Intl.DateTimeFormat("en-CA", { timeZone: "Europe/Budapest", year: "numeric", month: "2-digit", day: "2-digit", }) .format(now) .split("-") .map(Number); return { y, m, d }; }; /** 15 November to 6 January: gifts are Christmas gifts (festive card, e-mail). */ export function isChristmasTime(now = new Date()): boolean { const { m, d } = parts(now); return (m === 11 && d >= 15) || m === 12 || (m === 1 && d <= 6); } /** Christmas morning (24 December, 8:00 Budapest) of this season, if still ahead. */ export function christmasMorning(now = new Date()): Date | null { const { y, m } = parts(now); if (m !== 11 && m !== 12) return null; // 8:00 in Budapest is 7:00 UTC in December (winter time). const at = new Date(Date.UTC(y, 11, 24, 7, 0)); return at.getTime() > now.getTime() + 10 * 60 * 1000 ? at : null; }