Skip to content

Commit

Permalink
Fix test_time_zone_from_posix_tz in environments without a tzdb
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker authored and djc committed Sep 1, 2023
1 parent 0fce0d8 commit ecfad9e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/offset/local/tz_info/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,12 @@ mod tests {
assert_eq!(time_zone_local, time_zone_local_1);
}

let time_zone_utc = TimeZone::from_posix_tz("UTC")?;
assert_eq!(time_zone_utc.find_local_time_type(0)?.offset(), 0);
// `TimeZone::from_posix_tz("UTC")` will return `Error` if the environment does not have
// a time zone database, like for example some docker containers.
// In that case skip the test.
if let Ok(time_zone_utc) = TimeZone::from_posix_tz("UTC") {
assert_eq!(time_zone_utc.find_local_time_type(0)?.offset(), 0);
}
}

assert!(TimeZone::from_posix_tz("EST5EDT,0/0,J365/25").is_err());
Expand Down

0 comments on commit ecfad9e

Please sign in to comment.