Skip to main content
Version: 0.1.37

RFC3339 v1 (X7TS)

Module: ext.time.rfc3339

This module provides deterministic parsing/formatting of RFC3339 timestamps.

  • Standard: RFC3339 “Date and Time on the Internet: Timestamps”.
  • Extension: optional [TZID] suffix (IANA time zone name), preserving the zone name separately from the numeric offset.

Canonical API (v1)

  • parse_v1(s: bytes_view) -> bytes
  • format_v1(unix_s_lo: i32, unix_s_hi: i32, offset_s: i32, nanos_u32: i32, tzid: bytes) -> bytes
  • format_doc_v1(doc: bytes_view) -> bytes

Notes:

  • unix_s is signed i64, represented as (lo:u32, hi:u32) two’s complement.
  • offset_s is signed i32, seconds east of UTC (e.g. +3600 for +01:00).
  • Fractional seconds are normalized to nanoseconds (0..999_999_999).
  • tzid is UTF-8 bytes of an IANA time zone name (or empty). If present, formatting appends [TZID].

Parse result encoding (bytes doc)

parse_v1 returns a tagged bytes doc.

OK doc (tag = 1)

Byte layout (little-endian):

OffsetSizeFieldType
01tagu8 = 1
14unix_s_lou32
54offset_su32 (two’s complement i32)
94nanos_u32u32
134tzid_lenu32
17tzid_lentzid_bytesbytes
17+tzid_len4unix_s_hiu32

ERR doc (tag = 0)

OffsetSizeFieldType
01tagu8 = 0
14err_codeu32
54reservedu32

Pinned parse error codes:

  • SPEC_ERR_TS_INVALID = 1
  • SPEC_ERR_TS_RANGE = 2
  • SPEC_ERR_TS_BAD_TZID = 3
  • SPEC_ERR_TS_TRUNCATED = 4

Accessors

Accessors are pinned and must not change their offsets:

  • is_err(doc: bytes_view) -> i32
  • err_code(doc: bytes_view) -> i32
  • unix_s_u32(doc: bytes_view) -> i32 (lo)
  • unix_s_i64_hi(doc: bytes_view) -> i32 (hi)
  • offset_s(doc: bytes_view) -> i32
  • nanos_u32(doc: bytes_view) -> i32
  • tzid(doc: bytes_view) -> bytes