Skip to content

fix(stdlib): import time/tzdata for reliable timezone lookup in times.in_location - #488

Open
AdamMagued wants to merge 1 commit into
d5:masterfrom
AdamMagued:fix-issue-469-times-in-location
Open

AdamMagued wants to merge 1 commit into
d5:masterfrom
AdamMagued:fix-issue-469-times-in-location

Conversation

@AdamMagued

Copy link
Copy Markdown
Contributor

Summary

Import time/tzdata in stdlib/times.go so time.LoadLocation falls back to the embedded IANA timezone database when host zoneinfo is absent.

Problem

Calls to times.in_location(t, "Asia/Shanghai") fail with Runtime Error: unknown time zone Asia/Shanghai on operating systems without system zoneinfo (such as Windows) or in minimal container images.

Solution

Import _ "time/tzdata" in the stdlib package. The Go runtime uses the embedded database if the host system lacks timezone files. Add unit tests in stdlib/times_test.go covering standard timezone locations (Asia/Shanghai, UTC, America/New_York) and invalid location handling.

Fixes #469

@geseq geseq left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the failing CI please. The idea is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

times.in_location Runtime Error in Some Computer

2 participants