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 <trekkie@nomorestars.com>
This commit is contained in:
BeeHiggs
2026-08-13 16:22:48 -06:00
committed by GitHub
parent 430e66dac4
commit 9a305f3b6b

View File

@@ -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;