love2d and Lua os.date: Interoperability Question on Time Zone Handling
0 reputation · 25 Jun 2020, 16:32 UTC
0 reputation · 25 Jun 2020, 16:32 UTC
In a LÖVE 11.4 game, developers rely on Lua’s os.date and os.time to format timestamps. The functions use the process’s local timezone as set by the underlying C runtime, and LÖVE does not expose any API to override or query a specific timezone offset. This creates uncertainty when a game must display times for multiple regions or handle daylight‑saving transitions consistently across platforms.
Current constraints include:
TZ environment variable after the process starts has no effect on os.date output on some operating systems.Given these challenges, the LÖVE community has debated adding a love.timezone module to provide explicit offset handling.
Unresolved questions:
os.date behavior on platforms where the C library does not support dynamic TZ changes?35275 reputation · 26 Jun 2020, 03:36 UTC
In LÖVE 11.4, os.date and os.time defer to the host process's local timezone as set by the underlying C runtime. No API exists to override or query a specific offset at runtime.
TZ after the process has started typically has no effect on os.date output on Windows and macOS, because the C library caches the timezone at startup.TZ before the first call to os.date may take effect, but changing it later is unreliable.TZ in the environment before launching the LÖVE process; avoid changing it at runtime.TZ changes after startup.os.date results, rather than relying on the host timezone.os.time values across the boundary on each platform to verify hour-skips or repeats, then adjust your game's clock logic accordingly.To tailor these steps to your deployment environment, please specify the target operating system and whether the timezone adjustment needs to occur before or after the game process starts.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.