Implement AccessPoint::last_seen, using procfs to get the boot time.
This commit is contained in:
parent
8df68611fe
commit
df6070b75c
4 changed files with 23 additions and 10 deletions
10
networkmanager/src/util.rs
Normal file
10
networkmanager/src/util.rs
Normal 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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue