Expand description
Centralised timestamp utilities.
Mirrors ~/src/graphrefly-ts/src/core/clock.ts and the Python
core/clock.py. Convention: nanoseconds, _ns suffix, two clock domains
(monotonic for ordering, wall-clock for attribution) per CLAUDE.md
“Time utility rule.”
§Precision
monotonic_ns—std::time::Instantresolves to true nanoseconds on most modern platforms. Captured against a process-static origin (lazy viaOnceLock) so values fit inu64for ~584 years of process uptime.wall_clock_ns—SystemTime::now() - UNIX_EPOCHtruncated tou64nanoseconds; valid until ~2554. Beyond that, returnsu64::MAX. Pre-epoch system clocks (rare misconfiguration) return 0.
Mixing the two clocks is a bug — durations belong in monotonic; user-visible timestamps belong in wall-clock. The Core dispatcher uses monotonic exclusively.
Functions§
- monotonic_
ns - Monotonic nanosecond timestamp.
- wall_
clock_ ns - Wall-clock nanosecond timestamp (Unix epoch).