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) -> bytesformat_v1(unix_s_lo: i32, unix_s_hi: i32, offset_s: i32, nanos_u32: i32, tzid: bytes) -> bytesformat_doc_v1(doc: bytes_view) -> bytes
Notes:
unix_sis signed i64, represented as(lo:u32, hi:u32)two’s complement.offset_sis signed i32, seconds east of UTC (e.g. +3600 for+01:00).- Fractional seconds are normalized to nanoseconds (0..999_999_999).
tzidis 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):
| Offset | Size | Field | Type |
|---|---|---|---|
| 0 | 1 | tag | u8 = 1 |
| 1 | 4 | unix_s_lo | u32 |
| 5 | 4 | offset_s | u32 (two’s complement i32) |
| 9 | 4 | nanos_u32 | u32 |
| 13 | 4 | tzid_len | u32 |
| 17 | tzid_len | tzid_bytes | bytes |
| 17+tzid_len | 4 | unix_s_hi | u32 |
ERR doc (tag = 0)
| Offset | Size | Field | Type |
|---|---|---|---|
| 0 | 1 | tag | u8 = 0 |
| 1 | 4 | err_code | u32 |
| 5 | 4 | reserved | u32 |
Pinned parse error codes:
SPEC_ERR_TS_INVALID = 1SPEC_ERR_TS_RANGE = 2SPEC_ERR_TS_BAD_TZID = 3SPEC_ERR_TS_TRUNCATED = 4
Accessors
Accessors are pinned and must not change their offsets:
is_err(doc: bytes_view) -> i32err_code(doc: bytes_view) -> i32unix_s_u32(doc: bytes_view) -> i32(lo)unix_s_i64_hi(doc: bytes_view) -> i32(hi)offset_s(doc: bytes_view) -> i32nanos_u32(doc: bytes_view) -> i32tzid(doc: bytes_view) -> bytes