Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: Incorrect zonebounds on location based on POSIX TZ string #70633

Open
Achilleshiel opened this issue Dec 2, 2024 · 5 comments
Open

time: Incorrect zonebounds on location based on POSIX TZ string #70633

Achilleshiel opened this issue Dec 2, 2024 · 5 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Achilleshiel
Copy link

Achilleshiel commented Dec 2, 2024

Go version

go version go1.23.3 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN='/home/wouter/go/bin/'
GOCACHE='/home/wouter/.cache/go-build'
GOENV='/home/wouter/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/wouter/go/pkg/mod'
GONOPROXY='gitlab.figonet.nl'
GONOSUMDB='gitlab.figonet.nl'
GOOS='linux'
GOPATH='/home/wouter/go'
GOPRIVATE='gitlab.figonet.nl'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib64/golang'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib64/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/wouter/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='x86_64-solus-linux-gcc'
CXX='x86_64-solus-linux-g++'
CGO_ENABLED='1'
GOMOD='/home/wouter/Development/modules/sw_bca/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2766243939=/tmp/go-build -gno-record-gcc-switches'

What did you do?

My goal was to check if a posix tz string has the same time zone transitions as a given time.Location.
Via an empty Time zone information format string I loaded a Posix timezone string as location:
https://go.dev/play/p/iRKJ1idPNz6.
Using the loaded location I call ZoneBounds().

What did you see happen?

As from the go.dev/play example: it returns the end of DST and the end of the year.

What did you expect to see?

I expected to see get the end of DST and the start of the DST in the next year.

Debugging

I dug through the time library and found this comment:

	// The start and end values that we return are accurate
	// close to a daylight savings transition, but are otherwise
	// just the start and end of the year. That suffices for
	// the only caller that cares, which is Date.

This comment predates the addition of the ZoneBounds method. Which is now a second caller that cares.

@mknyszek mknyszek added this to the Backlog milestone Dec 2, 2024
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 2, 2024
@mknyszek
Copy link
Contributor

mknyszek commented Dec 2, 2024

CC @rsc via https://dev.golang.org/owners

@ianlancetaylor
Copy link
Member

You've identified the code. Do you want to send a patch? Thanks.

@Achilleshiel
Copy link
Author

Achilleshiel commented Dec 2, 2024

You've identified the code. Do you want to send a patch? Thanks.

Yes, I think I will be able to patch this. If not, I will let you know.

@Achilleshiel
Copy link
Author

Found that it is also possible with time.LoadLocation() and a time far enough in the future such that it is not in the explicit tz transitions. For example 2040: https://go.dev/play/p/h4ingW93eIU

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants