fix(ext/os): respect TZ environment variable on Windows (WIP)#34705
Draft
bartlomieju wants to merge 1 commit into
Draft
fix(ext/os): respect TZ environment variable on Windows (WIP)#34705bartlomieju wants to merge 1 commit into
bartlomieju wants to merge 1 commit into
Conversation
V8 derives its Date time zone from ICU. On unix ICU reads the TZ environment variable, but on Windows ICU detects the host time zone from the OS and ignores TZ, so a TZ set before launch (or via Deno.env.set) had no effect there (#15370). Apply TZ to ICU explicitly on Windows via the new v8::icu::set_default_time_zone, matching Node: - at startup (after init_platform) for TZ set in the environment, in both the CLI and the compiled-binary (denort) entry points; - in op_set_env's dt_change_notif when TZ is set at runtime, notifying the isolate with TimeZoneDetection::Skip so caches refresh without re-detecting (and overwriting) the zone just set; - in op_delete_env, which previously didn't refresh the zone at all. Unix keeps the existing tzset + Redetect path, which also handles non-IANA TZ formats. WIP: depends on denoland/rusty_v8#2000 and a v8 crate bump; the Windows code paths won't compile until that lands. Adds a tests/specs/run/tz_env regression test that runs on all platforms.
This was referenced Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP / draft — depends on denoland/rusty_v8#2000 (adds
v8::icu::set_default_time_zone) and a subsequentv8crate bump. TheWindows code paths are
#[cfg(windows)]-gated, so Linux/macOS builds andthe new spec test pass today; the Windows build stays red until the v8
bump lands.
Fixes #15370.
V8 derives its
Datetime zone from ICU. On unix ICU reads theTZenvironment variable, but on Windows ICU detects the host time zone from
the OS and ignores
TZ. So$env:TZ='UTC'; deno run ...(and evenDeno.env.set("TZ", ...)) had no effect on Windows, while Node honors iton every platform.
This applies
TZto ICU explicitly on Windows (matching Node'sSetDefaultTimeZone):init_platform, installTZfrom the environment inboth the CLI (
cli/lib.rs) and the compiled-binary / denort entry point(
cli/rt/run.rs), before any isolate usesDate;op_set_env'sdt_change_notif, set the zone andnotify the isolate with
TimeZoneDetection::Skipso cached valuesrefresh without re-detecting (and overwriting) what we just set;
op_delete_envnow refreshes the zone too — itpreviously didn't call
dt_change_notifat all, so unsettingTZnevertook effect.
Unix keeps the existing
tzset+Redetectpath, which also handlesnon-IANA
TZformats (e.g. POSIXPST8PDT).Adds
tests/specs/run/tz_env, which runs on all platforms and would havecaught the Windows regression.
TODO before un-drafting:
v8crate, drop the WIP note;TZedge cases warrant applying theexplicit path on all platforms instead of Windows-only.