Bun Intl.DateTimeFormat timeZone support and bundled tzdata update policy
0 reputation · 25 Dec 2020, 23:59 UTC
0 reputation · 25 Dec 2020, 23:59 UTC
Bun documents native Intl.DateTimeFormat support with a timeZone option for locale-specific formatting, and a Date constructor that parses ISO-8601 strings with or without a trailing Z.
The runtime is described as shipping its own bundled tzdata. Documentation does not clarify whether that tzdata is independent of the host OS, how it is versioned, or whether it is updated automatically with runtime releases. The handling of ambiguous local times, such as times that occur during DST transitions, is also not specified for parsing without an explicit offset.
For applications that rely on consistent regional time zone conversion across environments, the source and update policy of tzdata and the defined behavior for ambiguous local inputs are unresolved.
Does Bun use bundled tzdata independently of the host OS? Is the tzdata version tied to the runtime release and updated on a defined cadence? How is an ISO-8601 local time string interpreted when it falls within a DST gap or overlap?
35275 reputation · 26 Dec 2020, 09:01 UTC
Bun ships its own copy of the IANA Time‑Zone Database (tzdata) inside the runtime, independent of the host operating system. The bundled version is locked to the specific Bun release you run; updating the Bun binary is the only way to get a newer tzdata set. When parsing an ISO‑8601 string that lacks an explicit offset, Bun treats it as a local‑time value in the configured time zone. During a DST overlap or gap, the underlying JavaScriptCore implementation resolves the ambiguous instant by selecting the earlier or later offset according to its own algorithm (typically the earlier offset, but this is not guaranteed and can differ between JSC versions).
Z or explicit offset are parsed as local time in the current time zone. The resulting Date object will represent the instant that the host environment would interpret.Check the bundled tzdata version:
node -p "process.versions.tzdata"
or, if process.versions.tzdata is not available, run:
node -p "require('fs').readFileSync(process.execPath + '/tzdata.json', 'utf8').slice(0, 30)"
Both commands will print the tzdata snapshot identifier that ships with the binary.
Test a known DST transition date in two different Bun releases (e.g., 2023‑11‑05T01:30:00 in America/New_York) and compare the offsets. The difference in output indicates a tzdata update.
Parse a local ISO‑8601 string during a DST overlap:
new Date('2023-11-05T01:30:00') // no offset
console.log(new Date('2023-11-05T01:30:00').toString());
Observe which offset the runtime selects. Re‑run the code after upgrading Bun to see if the rule changes.
If your application depends on the most recent time‑zone rules (e.g., handling new DST changes or country‑specific adjustments), you should keep Bun up‑to‑date. The release notes for each Bun version usually list the tzdata snapshot used, so you can plan upgrades when a new snapshot is published.
To give a more precise recommendation for your environment, it would help to know which Bun version you are running (e.g., bun --version output). If you’re on an older release, the bundled tzdata may be several years out‑of‑date.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.