code wiki / (root) / iso8601.nx

iso8601.nx

buildroot/runtime/iso8601.nx

6599 B190 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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 · 1 importers

syscalls.nx civil_date.nx iso8601.nx atom.nx

imports: syscalls.nxcivil_date.nx

imported by: atom.nx

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

main iso_format_unix civil_from_unix cd_fdiv cd_fmod cd_fdiv ↻ iso_format iso_put_4d iso_put_2d iso_parse iso_parse_4d iso_parse_2d iso_parse_2d ↻ unix_from_civil cd_fdiv ↻ unix_from_civil ↻

structs

none

consts

31const ISO_ERR_FORMAT: i64 = -1
32const ISO_ERR_SHORT: i64 = -2

functions

35func iso_put_2d(out: *u8, off: i64, v: i64) -> i64 {
called by 1: iso_format
42func iso_put_4d(out: *u8, off: i64, v: i64) -> i64 {
called by 1: iso_format
52func iso_format(out: *u8, cap: i64, cd: *CivilDate) -> i64 {
71func iso_format_unix(out: *u8, cap: i64, unix_sec: i64) -> i64 {
79func iso_parse_2d(buf: *u8, off: i64) -> i64 {
90func iso_parse_4d(buf: *u8, off: i64) -> i64 {
called by 1: iso_parse calls 1: iso_parse_2d
101func iso_parse(buf: *u8, n: i64, unix_sec_out: *i64) -> i64 {
165func main() -> i64 {