diff options
| -rw-r--r-- | core/time/timezone/tz_unix.odin | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/core/time/timezone/tz_unix.odin b/core/time/timezone/tz_unix.odin index 990e78d41..542e5c4f2 100644 --- a/core/time/timezone/tz_unix.odin +++ b/core/time/timezone/tz_unix.odin @@ -81,9 +81,27 @@ _region_load :: proc(_reg_str: string, allocator := context.allocator) -> (out_r } defer if _reg_str == "local" { delete(reg_str, allocator) } - db_path := "/usr/share/zoneinfo" - region_path := filepath.join({db_path, reg_str}, allocator) - defer delete(region_path, allocator) + tzdir_str, tzdir_ok := os.lookup_env("TZDIR", allocator) + defer if tzdir_ok { delete(tzdir_str, allocator) } - return load_tzif_file(region_path, reg_str, allocator) + if tzdir_ok { + region_path := filepath.join({tzdir_str, reg_str}, allocator) + defer delete(region_path, allocator) + + if tz_reg, ok := load_tzif_file(region_path, reg_str, allocator); ok { + return tz_reg, true + } + } + + db_paths := []string{"/usr/share/zoneinfo", "/share/zoneinfo", "/etc/zoneinfo"} + for db_path in db_paths { + region_path := filepath.join({db_path, reg_str}, allocator) + defer delete(region_path, allocator) + + if tz_reg, ok := load_tzif_file(region_path, reg_str, allocator); ok { + return tz_reg, true + } + } + + return nil, false } |