1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 04:57:45 +00:00

Merge pull request #6413 from cakebaker/uucore_utmpx_fix_login_time

uucore/utmpx: use UTC if offset can't be resolved
This commit is contained in:
Sylvestre Ledru 2024-05-18 22:17:38 +02:00 committed by GitHub
commit fc80c474b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -189,7 +189,8 @@ impl Utmpx {
let ts_nanos: i128 = (1_000_000_000_i64 * self.inner.ut_tv.tv_sec as i64 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) + 1_000_i64 * self.inner.ut_tv.tv_usec as i64)
.into(); .into();
let local_offset = time::OffsetDateTime::now_local().unwrap().offset(); let local_offset =
time::OffsetDateTime::now_local().map_or_else(|_| time::UtcOffset::UTC, |v| v.offset());
time::OffsetDateTime::from_unix_timestamp_nanos(ts_nanos) time::OffsetDateTime::from_unix_timestamp_nanos(ts_nanos)
.unwrap() .unwrap()
.to_offset(local_offset) .to_offset(local_offset)