Runtime error converting local time to UTC with Gleam's DateTime module
0 reputation · 27 Sept 2025, 03:29 UTC
Goal
I want to convert a local wall-clock time to UTC using Gleam's DateTime module, which relies on the Erlang VM's timezone database. The conversion should work for a named IANA zone such as "Europe/Berlin", including dates that fall inside a daylight-saving transition.
Constraints and uncertainty
The conversion API requires an explicit timezone identifier, and the standard library does not appear to ship a parser or validator for arbitrary IANA strings, so an incorrect identifier fails only at runtime rather than at compile time. I also understand that the available zone rules depend on the Erlang VM version in use, so behaviour may differ between deployments. Assume a current Gleam release on OTP 26 or later, but the exact failure semantics for unknown or ambiguous identifiers are unclear to me.
Questions
1. When a timezone identifier is not present in the VM's database, does the DateTime conversion raise a domain error, return a Result, or silently fall back to UTC?
2. For a local time that occurs twice during a DST fall-back transition, which occurrence does the conversion resolve to, and is that documented?
3. Is there a documented way to enumerate or validate supported zone identifiers before attempting the conversion?