hypercall/shared/clock.rs
1use std::time::{SystemTime, UNIX_EPOCH};
2
3/// Current Unix time in whole seconds.
4///
5/// Panics if the system clock reads before the Unix epoch. Callers use this
6/// for expiry classification; a silent fallback to 0 would classify every
7/// expired instrument as live and reopen trading on it, so a crash is the
8/// correct failure mode.
9pub fn unix_now_secs() -> u64 {
10 SystemTime::now()
11 .duration_since(UNIX_EPOCH)
12 .unwrap_or_else(|e| {
13 panic!(
14 "CRITICAL_FAILURE: system clock reads before UNIX_EPOCH ({e}). \
15 Expiry classification cannot proceed with an invalid clock."
16 )
17 })
18 .as_secs()
19}