diff --git a/sursface/src/time.rs b/sursface/src/time.rs index 6e17ca1..df1b88a 100644 --- a/sursface/src/time.rs +++ b/sursface/src/time.rs @@ -10,29 +10,34 @@ mod platform_time { fn now() -> f64; } - pub fn now() -> f64 { + pub fn current_time() -> f64 { now() / 1000.0 // Convert milliseconds to seconds } } #[cfg(not(target_arch = "wasm32"))] mod platform_time { - use lazy_static::lazy_static; use std::time::Instant; + use lazy_static::lazy_static; lazy_static! { static ref TIME_AT_START: Instant = Instant::now(); } - pub fn now() -> f64 { + pub fn current_time() -> f64 { TIME_AT_START.elapsed().as_secs_f64() } } lazy_static! { - static ref TIME_AT_START: f64 = platform_time::now(); + static ref TIME_AT_START: f64 = platform_time::current_time(); } pub fn now() -> f32 { - (platform_time::now() - *TIME_AT_START) as f32 + (platform_time::current_time() - *TIME_AT_START) as f32 +} + +fn main() { + // Example usage + println!("Current time: {} seconds since start", now()); }