mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 04:57:45 +00:00
uucore/utmpx: use UTC if offset can't be resolved
This commit is contained in:
parent
4e0a256511
commit
90e023a9de
1 changed files with 2 additions and 1 deletions
|
@ -189,7 +189,8 @@ impl Utmpx {
|
|||
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();
|
||||
let local_offset =
|
||||
time::OffsetDateTime::now_local().map_or_else(|_| time::UtcOffset::UTC, |v| v.offset());
|
||||
time::OffsetDateTime::from_unix_timestamp_nanos(ts_nanos)
|
||||
.unwrap()
|
||||
.to_offset(local_offset)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue