Skip to content

Commit

Permalink
Merge pull request #4405 from bbara/utmpx-time
Browse files Browse the repository at this point in the history
utmpx: arch/os-independent timeval handling
  • Loading branch information
sylvestre authored Feb 22, 2023
2 parents 380b3cf + dd216ee commit 7da22b3
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/uucore/src/lib/features/utmpx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,9 @@ impl Utmpx {
}
/// A.K.A. ut.ut_tv
pub fn login_time(&self) -> time::OffsetDateTime {
#[cfg(all(not(target_os = "freebsd"), not(target_vendor = "apple")))]
let ts_nanos: i128 = (self.inner.ut_tv.tv_sec as i64 * 1_000_000_000_i64
+ self.inner.ut_tv.tv_usec as i64 * 1_000_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)
#[allow(clippy::unnecessary_cast)]
let ts_nanos: i128 = (1_000_000_000_i64 * self.inner.ut_tv.tv_sec as i64
+ 1_000_i64 * self.inner.ut_tv.tv_usec as i64)
.into();
let local_offset = time::OffsetDateTime::now_local().unwrap().offset();
time::OffsetDateTime::from_unix_timestamp_nanos(ts_nanos)
Expand Down

0 comments on commit 7da22b3

Please sign in to comment.