universal-time
Cross-platform time primitives for Rust that can run in any envuironment.
Why
universal-time gives you a single API for:
Instantfor monotonic elapsed-time measurementsSystemTimefor wall-clock timestamps- Trait-based clock injection for platforms without built-in time access
Quick Start
use ;
For more examples, check out the examples directory.
Panic Behavior
In no_std mode, and in std mode on wasm32-unknown-unknown, both
Instant::now() and SystemTime::now() panic when:
- no global context has been installed, or
- installed context returns
Nonefor that clock type
This is intentional so missing time sources fail fast instead of silently returning fake timestamps.
Concurrency Notes
std: global context usesOnceLockno_stdwith atomics: global context uses lock-free once initializationno_stdwithout atomics: fallback expects single-threaded startup initialization