mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #4405 from bbara/utmpx-time
utmpx: arch/os-independent timeval handling
This commit is contained in:
commit
7da22b3ae2
1 changed files with 3 additions and 7 deletions
|
@ -192,13 +192,9 @@ impl Utmpx {
|
||||||
}
|
}
|
||||||
/// A.K.A. ut.ut_tv
|
/// A.K.A. ut.ut_tv
|
||||||
pub fn login_time(&self) -> time::OffsetDateTime {
|
pub fn login_time(&self) -> time::OffsetDateTime {
|
||||||
#[cfg(all(not(target_os = "freebsd"), not(target_vendor = "apple")))]
|
#[allow(clippy::unnecessary_cast)]
|
||||||
let ts_nanos: i128 = (self.inner.ut_tv.tv_sec as i64 * 1_000_000_000_i64
|
let ts_nanos: i128 = (1_000_000_000_i64 * self.inner.ut_tv.tv_sec as i64
|
||||||
+ self.inner.ut_tv.tv_usec as i64 * 1_000_i64)
|
+ 1_000_i64 * self.inner.ut_tv.tv_usec as i64)
|
||||||
.into();
|
|
||||||
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
|
|
||||||
let ts_nanos: i128 = (self.inner.ut_tv.tv_sec * 1_000_000_000_i64
|
|
||||||
+ self.inner.ut_tv.tv_usec as i64 * 1_000_i64)
|
|
||||||
.into();
|
.into();
|
||||||
let local_offset = time::OffsetDateTime::now_local().unwrap().offset();
|
let local_offset = time::OffsetDateTime::now_local().unwrap().offset();
|
||||||
time::OffsetDateTime::from_unix_timestamp_nanos(ts_nanos)
|
time::OffsetDateTime::from_unix_timestamp_nanos(ts_nanos)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue