Skip to content

Commit

Permalink
Check TZDIR environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Apr 4, 2024
1 parent 470b1ce commit 9ba3069
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/offset/local/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ impl CachedTzInfo {
const ZONE_INFO_DIRECTORIES: [&str; 4] =
["/usr/share/zoneinfo", "/share/zoneinfo", "/etc/zoneinfo", "/usr/share/lib/zoneinfo"];

// Use the value of the `TZDIR` environment variable if set.
if let Some(tz_dir) = env::var_os("TZDIR") {
if !tz_dir.is_empty() {
let path = PathBuf::from(tz_dir);
if path.exists() {
return Ok(path);
}
}

Check warning on line 199 in src/offset/local/unix.rs

View check run for this annotation

Codecov / codecov/patch

src/offset/local/unix.rs#L193-L199

Added lines #L193 - L199 were not covered by tests
}

for dir in &ZONE_INFO_DIRECTORIES {
let path = PathBuf::from(dir);
if path.exists() {
Expand Down

0 comments on commit 9ba3069

Please sign in to comment.