code wiki / (root) / timefmt.nx

timefmt.nx

buildroot/runtime/timefmt.nx

8398 B240 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

timefmt.nx -- RFC 3339 + RFC 822 timestamp format/parse. Used by: - TLS 1.3 / X.509 cert validity (notBefore / notAfter). X.509 uses UTCTime (YYMMDDhhmmssZ) for dates before 2050 and GeneralizedTime (YYYYMMDDhhmmssZ) after. We support both formats for parse. - HTTP Date header (RFC 7231 ยง7.1.1.1) -- RFC 822 format. - Structured logs in Nishi services. - JSON responses (RFC 3339 via ISO 8601 subset). NO time zone handling today. All conversion is against UTC only; local time zones require a tz database we haven't built. TLS cert dates are always UTC, HTTP Date must be UTC-in-practice ("GMT"), so this covers the load-bearing cases. Format reference (RFC 3339): date-time = full-date "T" full-time full-date = date-fullyear "-" date-month "-" date-mday full-time = partial-time time-offset partial-time = hour ":" minute ":" second [ "." secfrac ] time-offset = "Z" / ( ("+" / "-") hour ":" minute ) We emit the "Z" form exclusively: "YYYY-MM-DDTHH:MM:SSZ" (20 chars). Invariants: T1 format_rfc3339 writes exactly 20 ASCII bytes plus NUL-free (caller adds terminator if needed) T2 Dates before year 1 are out of scope; years > 9999 are clamped to 9999 so the output stays 20 chars T3 No Y2K / 2038-bugginess. i64 epoch seconds handle every human-relevant date from ~292 BC to ~292 billion AD.

dependencies 1 imports · 1 importers

syscalls.nx timefmt.nx log.nx

imports: syscalls.nx

imported by: log.nx

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

main format_rfc3339 break_down_utc civil_from_days emit_zpad

structs

none

consts

none

functions

43func is_leap(y: i64) -> i64 {
52func days_from_civil(y: i64, m: i64, d: i64) -> i64 {
65func civil_from_days(days: i64, y_out: *i64, m_out: *i64, d_out: *i64) -> i64 {
called by 1: break_down_utc
88func break_down_utc(epoch_secs: i64,
called by 1: format_rfc3339 calls 1: civil_from_days
112func emit_zpad(out: *u8, pos: i64, n: i64, width: i64) -> i64 {
called by 1: format_rfc3339
125func format_rfc3339(epoch_secs: i64, out: *u8) -> i64 {
168func parse_2digit(buf: *u8, off: i64) -> i64 {
178func parse_4digit(buf: *u8, off: i64) -> i64 {
called by 1: parse_gentime calls 1: parse_2digit
188func parse_utctime(buf: *u8) -> i64 {
208func parse_gentime(buf: *u8) -> i64 {
225func main() -> i64 {
calls 1: format_rfc3339