aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Davidson <colrdavidson@gmail.com>2024-11-20 12:09:32 -0800
committerColin Davidson <colrdavidson@gmail.com>2024-11-20 12:09:32 -0800
commit3bb73eacfc458957da1e5863d497f0bda5c41438 (patch)
tree068ae67faf544b583cd661753d4dce789f93d86b
parent3229f4668dfaa5f43a374bc549f42661b002699d (diff)
fix parsing issue around utc/localtime split
-rw-r--r--core/time/timezone/tzif.odin17
-rw-r--r--tests/core/time/test_core_time.odin10
2 files changed, 17 insertions, 10 deletions
diff --git a/core/time/timezone/tzif.odin b/core/time/timezone/tzif.odin
index 609cbda73..bd93f6bb6 100644
--- a/core/time/timezone/tzif.odin
+++ b/core/time/timezone/tzif.odin
@@ -536,24 +536,21 @@ parse_tzif :: proc(_buffer: []u8, region_name: string, allocator := context.allo
buffer = buffer[(int(real_hdr.leapcnt) * size_of(Leapsecond_Record)):]
standard_wall_tags := buffer[:int(real_hdr.isstdcnt)]
- buffer = buffer[int(real_hdr.isstdcnt):]
-
- ut_tags := buffer[:int(real_hdr.isutcnt)]
-
for stdwall_tag, idx in standard_wall_tags {
- ut_tag := ut_tags[idx]
-
if (stdwall_tag != 0 && stdwall_tag != 1) {
return
}
- if (ut_tag != 0 && ut_tag != 1) {
- return
- }
+ }
+
+ buffer = buffer[int(real_hdr.isstdcnt):]
- if ut_tag == 1 && stdwall_tag != 1 {
+ ut_tags := buffer[:int(real_hdr.isutcnt)]
+ for ut_tag, idx in ut_tags {
+ if (ut_tag != 0 && ut_tag != 1) {
return
}
}
+
buffer = buffer[int(real_hdr.isutcnt):]
// Start of footer
diff --git a/tests/core/time/test_core_time.odin b/tests/core/time/test_core_time.odin
index 3bd4c3151..b72f57387 100644
--- a/tests/core/time/test_core_time.odin
+++ b/tests/core/time/test_core_time.odin
@@ -574,4 +574,14 @@ test_check_timezone_edgecases :: proc(t: ^testing.T) {
expected_tok_dt, _ := dt.components_to_datetime(2024, 10, 4, 9, 47, 0)
testing.expectf(t, datetime_eq(ret_dt, expected_tok_dt), "Failed to convert to Tokyo time")
+
+
+ tog_tz, tog_load_ok := tz.region_load("Pacific/Tongatapu")
+ testing.expectf(t, tog_load_ok, "Failed to load Pacific/Tongatapu timezone")
+ defer tz.region_destroy(tog_tz)
+
+ ret_dt = tz.datetime_to_tz(utc_dt, tog_tz)
+ expected_tog_dt, _ := dt.components_to_datetime(2024, 10, 4, 9, 47, 0)
+
+ testing.expectf(t, datetime_eq(ret_dt, expected_tog_dt), "Failed to convert to Togatapu time")
}