Expand description
Lua os standard library — os.* time/date arithmetic, environment, and
process control.
§Graduation (Idiomatization Sprint 2, Phase 2 — 2026-06-14)
The deterministic half of this module (the os.date/os.time broken-down
time arithmetic) is guarded by crates/lua-stdlib/tests/os_strengthen.rs,
pinned against the version-suffixed reference binaries. Net-strengthening came
FIRST and caught four real version divergences (our impl had applied the
modern 5.3+/5.4+ field- and specifier-validation rules to ALL versions); they
were fixed in get_field/os_time/os_date, single-source and version-gated.
The version gates are load-bearing — keep them explicit.
The time arithmetic is pure Rust, no unsafe, no libc bridge:
[decompose_utc]/[compose_utc] implement Howard Hinnant’s exact
proleptic-Gregorian algorithms, and [strftime_one] formats specifiers
directly. There is no gmtime_r/mktime/strftime FFI to keep.
§Impure surface (host-dependent — not reference-pinnable)
os.getenv/tmpname/remove/rename/execute/exit touch the real
environment, filesystem, and process; os.clock/os.time’s absolute value
and the locale/timezone specifiers (%z/%Z/%c/%x/%X/%r/%p/%P)
depend on the host clock/zone/locale. Those route through GlobalState hooks
(or std) for native/sandboxed/WASM hosts; only their arg-handling and
error-shape are reference-pinned, never their effects.
Structs§
- TmFields
- Local mirror of C’s
struct tm.
Constants§
- OS_LIB
- Mapping from Lua-visible names to the Rust implementations of each
os.*function.
Functions§
- open_os
- Opens the
oslibrary: creates a new table populated withOS_LIBand leaves it on the stack.
Type Aliases§
- Native
Fn - Signature of a Lua native function (the
os.*registration entries).