Files
site-builder/craft/scripts/fake-date-preload.cjs
T
shadowdaoandClaude Sonnet 5.5 01a78c9b3d catalog: omit the wall-clock-derived Countdown.targetDate default so the generated catalog (and drift test) no longer flip daily
Add a date-independence test (freezes Date at two different days via a preload).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-01 16:28:48 -08:00

10 lines
434 B
JavaScript

// Test helper: freeze the wall clock for a child process. FAKE_NOW=<ISO date> (node -r this).
const RealDate = Date;
const fixed = new RealDate(process.env.FAKE_NOW).getTime();
if (!Number.isFinite(fixed)) throw new Error('FAKE_NOW must be a valid ISO date');
class FakeDate extends RealDate {
constructor(...a) { if (a.length === 0) super(fixed); else super(...a); }
static now() { return fixed; }
}
globalThis.Date = FakeDate;