Skip to main content

platform_core/
clock.rs

1use chrono::{DateTime, Utc};
2use std::fmt::Debug;
3use std::sync::Arc;
4
5pub trait Clock: Debug + Send + Sync {
6    fn now(&self) -> DateTime<Utc>;
7}
8
9pub type DynClock = Arc<dyn Clock>;
10
11#[derive(Debug, Default)]
12pub struct SystemClock;
13
14impl Clock for SystemClock {
15    fn now(&self) -> DateTime<Utc> {
16        Utc::now()
17    }
18}