diff options
| author | Laytan <laytanlaats@hotmail.com> | 2025-12-15 19:06:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-15 19:06:16 +0100 |
| commit | 77606168b9d078f9de82379d4d7cfe550bc6a826 (patch) | |
| tree | 96c0fc6941aa4e9fd9c3b2ba3d61d08e79e57f2b | |
| parent | cf5987d5197aadb2b18e0dee03a9314c2fb7a87b (diff) | |
| parent | 916ec44ad17e0661e05b12bbc085250fd70d9b82 (diff) | |
Merge pull request #6012 from A1029384756/master
[tz_unix] added additional search paths to match musl
| -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 } |