nx_iso8601.nx
buildroot/runtime/nx_iso8601.nx
about
iso8601.nx -- format + parse ISO 8601 date-time strings.
The canonical machine-readable timestamp format:
2026-04-22T12:34:56Z
2026-04-22T12:34:56.123Z (milliseconds -- optional)
Used by: JSON APIs (the convention), HTTP Last-Modified headers
(RFC 7231 also accepts IMF-fixdate but ISO is simpler),
file export headers, nishi-pages post dates, obligation
deadlines, log timestamps.
We support the "basic profile" of ISO 8601:
YYYY-MM-DDTHH:MM:SS[.fff]Z (UTC only, 'Z' suffix)
Longer time-offset variants (+01:00, etc.) are NOT produced;
we always emit UTC. Parser accepts both 'Z' and an optional
'+HH:MM' / '-HH:MM' offset that we convert to seconds.
Composes civil_date.nx.
Invariants:
I1 Format output is exactly 20 bytes for seconds precision,
24 bytes for millisecond precision.
I2 Parser rejects strings with unknown fields (e.g. week
numbers) with ISO_ERR_FORMAT; we stay narrowly useful.
I3 Round-trip exact for format(parse(s)) on strings we emit.
dependencies 2 imports · 8 importers
imports: nx_syscalls.nxnx_civil_date.nx
imported by: nx_atom_v1.nxnx_circuit_breaker.nxnx_dead_letter_queue.nxnx_rate_limiter.nxnx_retry_policy.nxnx_smoke_harness.nxnx_source_adapter.nxnx_synthetic_upstream.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 36 | const ISO_MAGIC_3600: i64 = 3600 |
| 37 | const ISO_MAGIC_2026: i64 = 2026 |
| 39 | const ISO_ERR_FORMAT: i64 = -1 |
| 40 | const ISO_ERR_SHORT: i64 = -2 |
functions
| 43 | func iso_put_2d(out: *u8, off: i64, v: i64) -> i64 called by 1: iso_format |
| 50 | func iso_put_4d(out: *u8, off: i64, v: i64) -> i64 called by 1: iso_format |
| 60 | func iso_format(out: *u8, cap: i64, cd: *CivilDate) -> i64 |
| 79 | func iso_format_unix(out: *u8, cap: i64, unix_sec: i64) -> i64 |
| 87 | func iso_parse_2d(buf: *u8, off: i64) -> i64 |
| 98 | func iso_parse_4d(buf: *u8, off: i64) -> i64 |
| 109 | func iso_parse(buf: *u8, n: i64, unix_sec_out: *i64) -> i64 |
| 173 | func main() -> i64 |