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: IST is incorrectly parsed in Europe/Dublin #36529
Comments
This does work as expected when I pick a time when Daylight savings is actually on. For example, changing the month to June. |
A colleague pointed this out to me. From tzdata2019c, europe, line 529+:
Looks like the offset is coming from when there used to be a DMT. |
/cc @rsc |
Go's time package simply reflects the local system's timezone data. As far as I can tell, that is what is happening here, and there is no bug in Go. The data needs to be changed in tzdata instead. If you think there is a bug in Go, could you describe it more precisely? Thanks. |
I'm unsure whether there is a problem in Golang parser or not. Here's an example with the
The date command "correctly" rejects that when Daylight Savings is not "on", IST is an invalid timezone. The Golang parser on the other hand, converts it into Dublin Mean Time. Is that expected behavior? My quick read of the tzdata rules isn't comprehensive enough to understand whether this is expected. |
I also don't know what is correct. Currently what Go does is look up the name Perhaps we should use the last occurrence of the name in the time zone. |
That would still be a bad idea if you tried to use the Parser for times in the past. It may need more careful parsing based on the actual time. Is that supported or in scope? |
We don't currently have an API for asking whether a time is supported in a given timezone. And we don't reject dates because their timezone seems invalid, we just try to handle them as best we can. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
GOARCH="amd64" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPROXY="https://proxy.golang.org,direct" GOSUMDB="sum.golang.org" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build876647815=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I wrote a parser to parse time with 3-letter timezones in Europe/Dublin. I tried variations of IST/GMT/UTC/BST. All of those work fine except for IST when Daylight Savings is off. See example code: https://play.golang.org/p/3iNUKCLFC2l
What did you expect to see?
IST should be parsed similar to BST or at the very least not be partially parsed into an offset that doesn't exist.
2020-01-12 09:30 IST should be equal to 2020-01-12 08:30:00 +0000 GMT
What did you see instead?
2020-01-12 09:30 IST is parsed as 2020-01-12 08:55:21 +0000 GMT
The text was updated successfully, but these errors were encountered: