Skip to main content

Module timestamp

Module timestamp 

Source
Expand description

Canonical timestamp form for every temporal column (§4.1).

Every valid_from, valid_to, and recorded_at in the schema is compared lexicographically — by <= and < in SQL, by str ordering in Rust, and by MAX() when the clock recovers its floor. Lexicographic ordering agrees with chronological ordering only when every string has the same shape. A Z suffix alone is not enough:

'2026-01-01T00:00:00Z' <= '2026-01-01T00:00:00.000000Z'   -->  FALSE

because at the first differing byte 'Z' (0x5A) sorts after '.' (0x2E), so the second-precision instant compares as later than the identical microsecond-precision instant. A traversal predicated on valid_from <= :ts then silently drops every edge — no error, just an empty result.

The fix is to admit exactly one width. A timestamp is canonical iff it is exactly TIMESTAMP_LEN bytes in the form YYYY-MM-DDTHH:MM:SS.ffffffZ. CANONICAL_TS_GLOB enforces that at the storage layer so a non-canonical value cannot be written at all, and normalize widens the legacy second-precision form at the boundary rather than rejecting it.

Constants§

CANONICAL_TS_GLOB
GLOB pattern matching exactly the canonical form.
OPEN_SENTINEL
The open-interval sentinel, in canonical form.
TIMESTAMP_LEN
Byte length of the canonical form YYYY-MM-DDTHH:MM:SS.ffffffZ.

Functions§

format
Render a SystemTime in canonical form.
is_canonical
True iff s is exactly YYYY-MM-DDTHH:MM:SS.ffffffZ.
normalize
Widen a timestamp to canonical form.
parse
Strict parser for the canonical form (second precision accepted via normalize).