Implement AccessPoint::last_seen, using procfs to get the boot time.

This commit is contained in:
Lucy 2022-02-02 15:07:20 -05:00
parent 8df68611fe
commit df6070b75c
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
4 changed files with 23 additions and 10 deletions

View file

@ -0,0 +1,10 @@
// SPDX-License-Identifier: MPL-2.0
use time::OffsetDateTime;
pub fn clock_boottime_to_time(time: i32) -> Option<OffsetDateTime> {
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()
}