Skip to content

Commit

Permalink
Fall back to Tz::UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Apr 28, 2024
1 parent 727aa04 commit 11639d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/shims/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
// Figure out what time zone is in use
let tz = this.get_var(OsStr::new("TZ"))?.unwrap_or_else(|| OsString::from("UTC"));
let tz = match tz.into_string() {
Ok(tz) => Tz::from_str(&tz).unwrap_or(Tz::Zulu),
_ => Tz::Zulu,
Ok(tz) => Tz::from_str(&tz).unwrap_or(Tz::UTC),
_ => Tz::UTC,
};

// Convert that to local time, then return the broken-down time value.
Expand All @@ -156,7 +156,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

// tm_zone represents the timezone value in the form of: +0730, +08, -0730 or -08.
// This may not be consistent with libc::localtime_r's result.
let offset_in_seconds = Utc::now().with_timezone(&tz).offset().fix().local_minus_utc();
let offset_in_seconds = dt.offset().fix().local_minus_utc();
let tm_gmtoff = offset_in_seconds;
let mut tm_zone = String::new();
if offset_in_seconds < 0 {
Expand Down

0 comments on commit 11639d6

Please sign in to comment.