mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
utmpx: cast timeval fields to i64
This commit is contained in:
parent
4e7ae2d46a
commit
dd216ee23e
1 changed files with 3 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue