Skip to main content

LocalOffsetHook

Type Alias LocalOffsetHook 

Source
pub type LocalOffsetHook = fn(timestamp: i64) -> i64;
Expand description

Function-pointer signature for the host’s local timezone offset.

Given a Unix timestamp (seconds, UTC), returns the offset in seconds that the host’s local timezone applies at that instant, such that local_broken_down = gmtime(timestamp + offset). Positive east of UTC (e.g. +3600 for CET), negative west (e.g. -14400 for US EDT). This backs the local-time semantics of os.date (non-! formats) and os.time, which C implements with localtime_r/mktime. Reading the host timezone database requires libc FFI (unsafe), banned in lua-stdlib, so the host installs this hook. When unset the stdlib uses UTC (offset 0), keeping the os.date/os.time round-trip exact on hosts without a timezone.