-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
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?
package main
import (
"time"
)
func main() {
loc, err := time.LoadLocation("Europe/Istanbul")
if err != nil {
panic("Cannot load Timezone: " + err.Error())
}
timeStamp := time.Date(2018, 02, 23, 0, 0, 0, 0, loc)
layout := "2006-01-02 15:04:05 MST"
_, err = time.Parse(layout, timeStamp.Format(layout))
if err != nil {
panic("Cannot Parse Time: " + err.Error())
}
}
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"