test(#2136): add localToday regression + mirror fake/inline clock stubs
Adds a dedicated regression (tests/fix-2136-clock-local-today.test.cjs): - realClock.localToday() returns the LOCAL calendar day under a pinned instant + TZ (America/Chicago → 2020-06-14, the issue's repro instant). - realClock.today() is unchanged (UTC) — internal/cosmetic stamps stay UTC. - localToday === today on a UTC host (no spurious divergence). - makeFakeClock mirrors localToday (drop-in Clock substitute). - field-level: a 'sync' transition with a split clock (today≠localToday) writes the LOCAL day into Last Activity, proving the wiring uses localToday. Mirrors localToday() in the fake clock helper and the inline fixedClock stubs in state-transition.test.cjs / state-rebuild.test.cjs (the Clock interface now requires it).
This commit is contained in:
@@ -90,6 +90,20 @@ function makeFakeClock(startMs) {
|
||||
return new Date(_now).toISOString().split('T')[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the virtual date as a YYYY-MM-DD string in the HOST-LOCAL calendar
|
||||
* day. Mirrors realClock.localToday() so fake clocks are drop-in substitutes.
|
||||
* (#2136: operator-facing date-only fields use the local calendar day.)
|
||||
*
|
||||
* @returns {string} e.g. "2020-06-14" (local), may differ from today() near UTC midnight
|
||||
*/
|
||||
localToday() {
|
||||
const d = new Date(_now);
|
||||
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
||||
const dd = String(d.getDate()).padStart(2, '0');
|
||||
return d.getFullYear() + '-' + mm + '-' + dd;
|
||||
},
|
||||
|
||||
/** Array of ms values passed to sleep() in call order. */
|
||||
get sleepCalls() {
|
||||
return _sleepCalls;
|
||||
|
||||
Reference in New Issue
Block a user