1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use std::time::Duration; extern "C" { fn seconds_now() -> f64; } #[cfg(not(target_arch = "wasm32"))] pub fn now() -> Duration { use std::time::SystemTime; let time = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) .unwrap_or_else(|e| panic!(e)); time } #[cfg(target_arch = "wasm32")] pub fn now() -> Duration { unsafe { Duration::from_secs_f64(crate::date::seconds_now()) } }