Skip to content

Commit 9ba3069

Browse files
committed
Check TZDIR environment variable
1 parent 470b1ce commit 9ba3069

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/offset/local/unix.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ impl CachedTzInfo {
189189
const ZONE_INFO_DIRECTORIES: [&str; 4] =
190190
["/usr/share/zoneinfo", "/share/zoneinfo", "/etc/zoneinfo", "/usr/share/lib/zoneinfo"];
191191

192+
// Use the value of the `TZDIR` environment variable if set.
193+
if let Some(tz_dir) = env::var_os("TZDIR") {
194+
if !tz_dir.is_empty() {
195+
let path = PathBuf::from(tz_dir);
196+
if path.exists() {
197+
return Ok(path);
198+
}
199+
}
200+
}
201+
192202
for dir in &ZONE_INFO_DIRECTORIES {
193203
let path = PathBuf::from(dir);
194204
if path.exists() {

0 commit comments

Comments
 (0)