#![forbid(unsafe_code)]
use std::time::{SystemTime, UNIX_EPOCH};
use chio_kernel_core::Clock;
#[derive(Debug, Clone, Copy, Default)]
pub struct MobileClock;
impl MobileClock {
#[must_use]
pub const fn new() -> Self {
Self
}
}
impl Clock for MobileClock {
fn now_unix_secs(&self) -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_secs())
.unwrap_or(0)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn mobile_clock_returns_recent_timestamp() {
let clock = MobileClock::new();
let now = clock.now_unix_secs();
assert!(now > 1_577_836_800);
}
}