refactor: replace time with jiff

Also updates the `timedatectl` example from `chrono` to `jiff`.
This commit is contained in:
Vukašin Vojinović 2026-03-13 14:17:49 +01:00 committed by Michael Murphy
parent 0fa672f8da
commit cc80763ffc
10 changed files with 41 additions and 46 deletions

View file

@ -8,14 +8,13 @@ use crate::{
util::clock_boottime_to_time,
};
use std::ops::Deref;
use time::OffsetDateTime;
use zbus::Result;
#[derive(Debug)]
pub struct AccessPoint<'a>(AccessPointProxy<'a>);
impl<'a> AccessPoint<'a> {
pub async fn last_seen(&self) -> Result<Option<OffsetDateTime>> {
pub async fn last_seen(&self) -> Result<Option<jiff::Timestamp>> {
Ok(clock_boottime_to_time(self.0.last_seen().await?))
}

View file

@ -1,10 +1,10 @@
// SPDX-License-Identifier: MPL-2.0
use time::OffsetDateTime;
use jiff::Timestamp;
pub fn clock_boottime_to_time(time: i32) -> Option<OffsetDateTime> {
pub fn clock_boottime_to_time(time: i32) -> Option<Timestamp> {
let boot_time = procfs::boot_time_secs()
.ok()
.and_then(|boot_time| i64::try_from(boot_time).ok())?;
OffsetDateTime::from_unix_timestamp(boot_time + time as i64).ok()
Timestamp::from_second(boot_time + time as i64).ok()
}