aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2025-10-30 13:45:59 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2026-02-08 12:48:51 +0100
commitc265d297b5c9252db391cdf43eca079d8f634791 (patch)
treeb24ead72c59843393e5f67e3c1f951f5ba307bdf
parent67db0fde4fbfaf34870b5f5ac3042c50df9a0c2c (diff)
core:time/timezone -> os2
-rw-r--r--core/time/timezone/tz_unix.odin15
-rw-r--r--core/time/timezone/tzif.odin18
2 files changed, 19 insertions, 14 deletions
diff --git a/core/time/timezone/tz_unix.odin b/core/time/timezone/tz_unix.odin
index 542e5c4f2..e4121266d 100644
--- a/core/time/timezone/tz_unix.odin
+++ b/core/time/timezone/tz_unix.odin
@@ -2,16 +2,16 @@
#+private
package timezone
-import "core:os"
-import "core:strings"
-import "core:path/filepath"
-import "core:time/datetime"
+import os "core:os/os2"
+import "core:strings"
+import "core:path/filepath"
+import "core:time/datetime"
local_tz_name :: proc(allocator := context.allocator) -> (name: string, success: bool) {
local_str, ok := os.lookup_env("TZ", allocator)
if !ok {
orig_localtime_path := "/etc/localtime"
- path, err := os.absolute_path_from_relative(orig_localtime_path, allocator)
+ path, err := os.get_absolute_path(orig_localtime_path, allocator)
if err != nil {
// If we can't find /etc/localtime, fallback to UTC
if err == .ENOENT {
@@ -28,7 +28,10 @@ local_tz_name :: proc(allocator := context.allocator) -> (name: string, success:
// This is a hackaround, because FreeBSD copies rather than softlinks their local timezone file,
// *sometimes* and then stores the original name of the timezone in /var/db/zoneinfo instead
if path == orig_localtime_path {
- data := os.read_entire_file("/var/db/zoneinfo", allocator) or_return
+ data, data_err := os.read_entire_file("/var/db/zoneinfo", allocator)
+ if data_err != nil {
+ return "", false
+ }
return strings.trim_right_space(string(data)), true
}
diff --git a/core/time/timezone/tzif.odin b/core/time/timezone/tzif.odin
index 804211ef4..7a7023c6c 100644
--- a/core/time/timezone/tzif.odin
+++ b/core/time/timezone/tzif.odin
@@ -1,12 +1,11 @@
package timezone
-import "base:intrinsics"
-
-import "core:slice"
-import "core:strings"
-import "core:os"
-import "core:strconv"
-import "core:time/datetime"
+import "base:intrinsics"
+import "core:slice"
+import "core:strings"
+import os "core:os/os2"
+import "core:strconv"
+import "core:time/datetime"
// Implementing RFC8536 [https://datatracker.ietf.org/doc/html/rfc8536]
@@ -70,7 +69,10 @@ tzif_data_block_size :: proc(hdr: ^TZif_Header, version: TZif_Version) -> (block
load_tzif_file :: proc(filename: string, region_name: string, allocator := context.allocator) -> (out: ^datetime.TZ_Region, ok: bool) {
- tzif_data := os.read_entire_file_from_filename(filename, allocator) or_return
+ tzif_data, tzif_err := os.read_entire_file(filename, allocator)
+ if tzif_err != nil {
+ return nil, false
+ }
defer delete(tzif_data, allocator)
return parse_tzif(tzif_data, region_name, allocator)
}