From 9a305f3b6b3d16f7f94c3ab24fc77e094a6da50e Mon Sep 17 00:00:00 2001 From: BeeHiggs Date: Thu, 13 Aug 2026 16:22:48 -0600 Subject: [PATCH] fix(#3367): expectedQuickId derives UTC values to match the TZ-pinned subprocess (#3398) expectedQuickId() in tests/init.test.cjs computed its expected quick_id using local-time Date getters (getFullYear/getMonth/getDate/getHours/ getMinutes/getSeconds) in the test-runner process, while the CLI subprocess under test is pinned to TZ=UTC. The two sides only agreed when the test-runner's own ambient TZ happened to already be UTC. Swap the six getters to their getUTC* equivalents so the helper is timezone-invariant. No change to src/init.cts (the CLI side already relies on its own UTC-pinned subprocess env and is correct) and no change to the pinned clock instants or expected quick_id strings asserted by the three affected tests. Introduced by 80734a969 (#3332). Co-authored-by: Tom Boucher --- tests/init.test.cjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/init.test.cjs b/tests/init.test.cjs index 40c70e06e..be00977e5 100644 --- a/tests/init.test.cjs +++ b/tests/init.test.cjs @@ -1733,11 +1733,11 @@ describe('cmdInitQuick quick_id — exact value under GSD_NOW_MS+TZ pin', () => // runtime output — so this test can actually catch a broken implementation. function expectedQuickId(ms) { const d = new Date(ms); - const yy = String(d.getFullYear()).slice(-2); - const mm = String(d.getMonth() + 1).padStart(2, '0'); - const dd = String(d.getDate()).padStart(2, '0'); + const yy = String(d.getUTCFullYear()).slice(-2); + const mm = String(d.getUTCMonth() + 1).padStart(2, '0'); + const dd = String(d.getUTCDate()).padStart(2, '0'); const dateStr = yy + mm + dd; - const secondsSinceMidnight = d.getHours() * 3600 + d.getMinutes() * 60 + d.getSeconds(); + const secondsSinceMidnight = d.getUTCHours() * 3600 + d.getUTCMinutes() * 60 + d.getUTCSeconds(); const timeBlocks = Math.floor(secondsSinceMidnight / 2); const timeEncoded = timeBlocks.toString(36).padStart(3, '0'); return dateStr + '-' + timeEncoded;