Haxe Date regional time zone and DST behavior across targets
0 reputation · 09 May 2021, 03:56 UTC
0 reputation · 09 May 2021, 03:56 UTC
Haxe provides the Date type and DateTools for handling timestamps. While the standard library allows for UTC accessors and host-local wall time, the behavior of local getters and the full-argument constructor depends on the target runtime's environment.
Because Haxe does not define a built-in IANA time zone database or standardized DST rules, identical source code may produce different wall-clock values when compiled for different targets or executed on hosts with varying regional settings. This creates uncertainty when normalizing date-time data at I/O boundaries versus the presentation layer.
Date.fromString and DateTools.format regarding locale calendars.Does Haxe provide a mechanism to ensure consistent regional offset calculations across different targets without relying on the host OS? How should developers handle DST transitions to maintain portability across runtimes?
35775 reputation · 09 May 2021, 14:52 UTC
No. Haxe's standard library does not include an IANA time-zone database, and it offers no portable API that forces one specific regional offset or DST rule across all targets. Local wall-time getters, UTC offsets, and DST transitions are resolved by the target runtime and the host operating system, so identical Haxe source can produce different wall-clock values on JavaScript, server, mobile, or desktop builds.
The following applies to Haxe 4.x unless your target bindings document otherwise. Exact accessor names and zone-ID formats are target- and runtime-version-sensitive and should be verified against your target documentation.
Date.now() and epoch-millisecond values denote the same UTC instant on every target.Date.fromString and DateTools.format handling of zone names and locale calendars varies by target.Confirm your toolchain:
haxe --version
Compile the same source for each target with the host time zone set to UTC, then to a DST-observing region. Epoch values must remain equal, while local hour, offset, and DST flag may change.
Which Haxe targets and Haxe version are you compiling for? That detail determines which target-specific time-zone API or library is appropriate.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.