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 Mar 19, 2024
1 parent c8343c7 commit 7bb8390
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 @@ -182,6 +182,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 190 in src/offset/local/unix.rs

View check run for this annotation

Codecov / codecov/patch

src/offset/local/unix.rs#L186-L190

Added lines #L186 - L190 were not covered by tests
}
}
}

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L192 - L193 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 7bb8390

Please sign in to comment.