code wiki / (root) / nx_ts.nx

nx_ts.nx

buildroot/runtime/nx_ts.nx

8047 B210 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic ts
docsdependenciesstructsconstsfunctions

about

nx_ts.nx -- Unix epoch <-> calendar / ISO-8601 conversion. nx_log writes timestamps as raw seconds-since-epoch. That's machine-readable but not human-readable: you can't tell at a glance whether a log line was 2 minutes ago or 2 weeks ago. This module provides: - epoch -> (year, month, day, hour, min, sec) calendar tuple using the Howard Hinnant civil-from-days algorithm (no lookup tables, no floating point, exact). - calendar -> ISO-8601 string formatter ("2026-04-25T03:14:07Z") Reference: Hinnant, "chrono-Compatible Low-Level Date Algorithms", http://howardhinnant.github.io/date_algorithms.html Pairs with nx_log + nx_strfmt. No timezone handling -- we always emit UTC ('Z' suffix). TZ awareness can come later if anyone actually needs it.

dependencies 1 imports · 0 importers

syscalls.nx nx_ts.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_ts_from_epoch nx_ts_civil_from_days nx_ts_format_iso nx_ts_from_epoch ↻ nx_ts_write4 nx_ts_write2

structs

40struct NxTsCal

consts

27const NX_MAGIC_719468: i64 = 719468
28const NX_MAGIC_146097: i64 = 146097
29const NX_MAGIC_146096: i64 = 146096
30const NX_MAGIC_1460: i64 = 1460
31const NX_MAGIC_36524: i64 = 36524
32const NX_MAGIC_3600: i64 = 3600
33const NX_MAGIC_9999: i64 = 9999
34const NX_MAGIC_1970: i64 = 1970
35const NX_MAGIC_1234567890: i64 = 1234567890
36const NX_MAGIC_2009: i64 = 2009
37const NX_MAGIC_951782400: i64 = 951782400
38const NX_MAGIC_2000: i64 = 2000
49const NX_TS_CAL_BYTES: i64 = 48
52const NX_TS_DAYS_PER_YEAR: i64 = 365
54const NX_TS_SECS_PER_DAY: i64 = 86400

functions

60func nx_ts_civil_from_days(z: i64, out: *NxTsCal) -> i64
called by 1: nx_ts_from_epoch
82func nx_ts_from_epoch(epoch_secs: i64, out: *NxTsCal) -> i64
109func nx_ts_write2(buf: *u8, off: i64, v: i64) -> i64
called by 1: nx_ts_format_iso
121func nx_ts_write4(buf: *u8, off: i64, v: i64) -> i64
called by 1: nx_ts_format_iso
141func nx_ts_format_iso(epoch_secs: i64, buf: *u8) -> i64
171func main() -> i64