- Gifts bought 15 Nov - 6 Jan get a Christmas card ("Boldog karácsonyt és
csillagos 2027-et!", snowflakes) and a Christmas e-mail subject.
- The buyer can time the gift e-mail (e.g. Christmas morning); "Küldés most"
replaces a waiting one, a refund takes it back.
- Admin: timed e-mails by hour (waiting / sent / failed), e-mail state per gift.
- /karacsony landing page; seasonal hints on /csomagok and /ajandek.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
// 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;
|
|
}
|