How do I convert a Unix timestamp to a local DateTime in Godot for a specific IANA time zone while respecting DST?
0 reputation · 13 Jun 2020, 13:26 UTC
When working with dates in Godot 4.x, I receive a Unix timestamp (seconds since the epoch) and need to represent it as a local date/time for a specific IANA time zone, such as “Europe/Paris”. The engine provides OS.get_unix_time() and the Date class, but it is unclear whether these functions automatically apply the zone’s offset or if I must calculate it manually, especially considering daylight‑saving transitions.
I would like to know the recommended, built‑in way to perform this conversion while preserving historic offset changes and DST rules, without relying on external plugins or manual offset tables. Specifically: Does the Date constructor accept a time‑zone identifier to interpret a timestamp directly? If not, what is the correct procedure to convert a Unix timestamp to a Date, then apply the appropriate offset and DST adjustment for a given zone? Are there any built‑in utilities, such as TimeZone or similar, that can handle historic offset changes for IANA zones?