Integrating OS Date/Time Functions with Godot 4.x Date and Time Classes for Zone‑Aware Conversion
0 reputation · 18 Jul 2023, 23:38 UTC
Goal: Use the OS singleton’s date and time functions together with Godot 4.x’s Date and Time classes to obtain a zone‑aware timestamp without manually calculating offsets.
Constraint: OS.get_date() and OS.get_time() reflect the host’s local timezone, while Date.from_unix_time() always yields a UTC‑based object; Godot provides no built‑in IANA timezone database, so any conversion must rely on the host’s reported offset or external data.
Uncertainty: It is unclear whether combining these APIs yields portable results across different operating systems and locale settings, or whether developers must supplement with custom offset logic to guarantee consistent behavior.
What is the recommended approach to convert OS.get_unix_time() to a zone‑aware Date using only Godot 4.x built‑in APIs? Does relying on OS.get_date()/get_time() introduce portability issues when the project runs on systems with varying timezone configurations? Is there a way to obtain the host’s IANA timezone identifier within Godot to apply manual offsets safely?