timestamp.ts

The canonical wire timestamp shape shared by the two spine implementations.

Every timestamp that reaches the wire is second-precision UTC — YYYY-MM-DDTHH:MM:SSZ, exactly 20 characters. Timestamps read from Postgres get that shape from the SQL projection (iso8601_timestamp_column in db/sql_columns.ts, twin of fuz_db::iso8601_timestamp_column); this module is the same shape for the stamps minted in TS rather than read back from a row, so the two sources agree and the two backends serialize the same instant to the same bytes.

view source

Declarations
#

4 declarations

is_iso8601_seconds_live
#

timestamp.ts view source

(stamp: string, now_ms: number): boolean import {is_iso8601_seconds_live} from '@fuzdev/fuz_app/timestamp.js';

Whether the second a wire timestamp names has not yet ended.

The one in-memory expiry rule over a truncated stamp: stamp stands for [stamp, stamp + ISO8601_SECOND_MS), so this admits until that whole second is over and can never report an expiry the server's raw-column expires_at > NOW() gate would still accept. A stamp that does not parse is never live.

stamp

a second-precision wire timestamp

type string

now_ms

the current time in epoch milliseconds

type number

returns

boolean

true while now_ms lies before the end of stamp's second

ISO8601_SECOND_MS
#

timestamp.ts view source

1000 import {ISO8601_SECOND_MS} from '@fuzdev/fuz_app/timestamp.js';

The width of one wire timestamp, in milliseconds.

A wire stamp is truncated, not rounded, so the instant it names lies anywhere in [stamp, stamp + ISO8601_SECOND_MS). A predicate that must not fire early against a stamp — "has this expiry passed?" — adds this to reach the end of the second the stamp stands for.

ISO8601_SECONDS
#

timestamp.ts view source

RegExp import {ISO8601_SECONDS} from '@fuzdev/fuz_app/timestamp.js';

The canonical wire timestamp shape as a regex — second-precision UTC, exactly 20 characters.

Lives in library code rather than a test helper so the unit suites, the db suites, and the cross-backend suites all pin the same pattern the server renders.

to_iso8601_seconds
#

timestamp.ts view source

(date: Date): string import {to_iso8601_seconds} from '@fuzdev/fuz_app/timestamp.js';

Render a Date as the canonical second-precision UTC wire timestamp (YYYY-MM-DDTHH:MM:SSZ).

Truncates rather than rounds, mirroring Postgres' to_char(…, 'YYYY-MM-DD"T"HH24:MI:SS"Z"') and the Rust spine's fuz_sys::rfc3339_now.

date

the instant to render

type Date

returns

string

the 20-character UTC timestamp

Imported by
#