Local time not required

This is my first time posting from Japan.
Is TimeZone wrong?
There was no problem with New_York time, but I can’t find Japan time.

package main

import "core:fmt"
import "core:time"
import "core:time/datetime"
import "core:time/timezone"

main :: proc() {
    tz, tz_err := timezone.region_load("Asia/Tokyo") // true
    // tz, tz_err := timezone.region_load("America/New_York") // true
    fmt.println("timezone: ", tz, tz_err)

    dt, _ := time.time_to_datetime( time.now() )
    fmt.println("datetime: ", dt)

    dt_jp, dt_jp_err := timezone.datetime_to_tz(dt, tz)
    fmt.println("japan datetime: ", dt_jp, dt_jp_err)
}

As a result, the program crashes

timezone:  &TZ_Region{name = "Asia/Tokyo", records = [], shortnames = [], rrule = TZ_RRule{has_dst = true, std_name = "JST", std_offset = 32400, std_date = TZ_Transition_Date{type = "Month_Week_Day", month = 0, week = 0, day = 0, time = 0}, dst_name = "JST", dst_offset = 36000, dst_date = TZ_Transition_Date{type = "Month_Week_Day", month = 0, week = 0, day = 0, time = 0}}} true
datetime:  DateTime{date = Date{year = 2024, month = 11, day = 5}, time = Time{hour = 10, minute = 32, second = 7, nano = 244868100}, tz = <nil>}
E:/Dev/lang/odin/core/time/timezone/tzdate.odin(77:21) Index -1 is out of range 0..<12

my PC environment
Windows 11
odin.exe version dev-2024-11-nightly

1 Like

It finds the Tokyo TZ just fine. The problem is that the transition date has all zeroes for its components, which is something Cloin must have not encountered during development.

Seems like it’s not able to get values from registry or something. I looked over the code a bit. It’s probably a bug.

Thank you for contacting us

I’ll document it as a bug in the issue.

1 Like

Fixed: add new test, better fail-check, and non-transitioning tz fix by colrdavidson · Pull Request #4456 · odin-lang/Odin · GitHub

Thank you for your response.
I’ll close it.
I was surprised by the quick response.

1 Like