shifty-backend/service_impl/src/clock.rs
2024-05-02 23:25:04 +02:00

16 lines
474 B
Rust

use service::clock::ClockService;
use time::OffsetDateTime;
pub struct ClockServiceImpl;
impl ClockService for ClockServiceImpl {
fn time_now(&self) -> time::Time {
OffsetDateTime::now_utc().time()
}
fn date_now(&self) -> time::Date {
OffsetDateTime::now_utc().date()
}
fn date_time_now(&self) -> time::PrimitiveDateTime {
let now = OffsetDateTime::now_utc();
time::PrimitiveDateTime::new(now.date(), now.time())
}
}