You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
ianlancetaylor
changed the title
time.parseTimeZone() doesn't work for for many Zones formatted by Time.Format()
time: parseTimeZone() doesn't work for for many Zones formatted by Time.Format()
Feb 23, 2018
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 +03, but there is no timezone with that abbreviation. As the docs for time.Parse say, using MST in the parse string only matches defined timezones, and there is no timezone named +03 on your system.
It is not a goal that time.Time.Format and time.Parse be exact reverses of each other. In general, that is impossible, as is demonstrated by this case.
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: