-
Notifications
You must be signed in to change notification settings - Fork 18k
time: parseTimeZone() doesn't work for for many Zones formatted by Time.Format() #24071
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
Comments
The timezone handling by the time package is entirely dependent on the files supplied by your operating system. As you have shown, due to changes in the way that Turkey handles time zones, the files on your system print some dates in the Europe/Istanbul timezone using It is not a goal that Use Closing because there is nothing we can do. |
Actually that is not completely true, as it can be matched on the system and the error is generated before trying to match it. time.Parse calls time.ParseTimeZone() which then rejects this as it does not fit into the scheme having at least three upper case letters and a T in the end, see: adding a third special case like: and packing my example into a test in that package shows that this is easily solvable. I am also willing to fix that using a bit more sophisticated special case then shown above, if this bug gets accepted. |
OK, sure, let's try that. |
Change https://golang.org/cl/98157 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.9.4
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/kasch/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kasch/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build708812266=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Example in Go Playground
some Timezones from IANA database do get parsed correctly (eg. Europe/Istanbul)
see tz database +03 is used as timezone: https://github.com/eggert/tz/blob/6df98f4244eaa5ef9af50d71020faa9364b52f09/europe#L3738
there are more Timezones using times Like this one
What did you expect to see?
no panic, as I assume that the time package should be able to read every timestamp it produces with the same layout string
What did you see instead?
panic: Cannot Parse Time: parsing time "2018-02-23 00:00:00 +03" as "2006-01-02 15:04:05 MST": cannot parse "+03" as "MST"
The text was updated successfully, but these errors were encountered: