Skip to content

time: time.LoadLocation returns incorrect time zone #34101

@stishenok

Description

@stishenok

What version of Go are you using (go version)?

$ go version
go version go1.11.4 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/stishenok/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/stishenok/go"
GOPROXY="direct"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/stishenok/go/src/github.com/test/go.mod"
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=/var/folders/8p/t619jr29323dksvz22f_5z400000gn/T/go-build839715032=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

import (
	"fmt"
	"time"
)

func main() {
	locAmsterdam, err := time.LoadLocation("Europe/Amsterdam")
	if err != nil {
		panic(err)
	}
	timeAmsterdam, err := time.ParseInLocation("15:04", "13:40", locAmsterdam)
	if err != nil {
		panic(err)
	}

	locBerlin, err := time.LoadLocation("Europe/Berlin")
	if err != nil {
		panic(err)
	}
	timeBerlin, err := time.ParseInLocation("15:04", "13:40", locBerlin)
	if err != nil {
		panic(err)
	}

	fmt.Println("Location : ", timeAmsterdam.Location(), " Time : ", timeAmsterdam)
	fmt.Println("Location : ", timeBerlin.Location(), " Time : ", timeBerlin)
}

What did you expect to see?

Location : Europe/Amsterdam Time : 0000-01-01 13:40:00 +0100 CET
Location : Europe/Berlin Time : 0000-01-01 13:40:00 +0100 CET

What did you see instead?

Location : Europe/Amsterdam Time : 0000-01-01 13:40:00 +0019 AMT
Location : Europe/Berlin Time : 0000-01-01 13:40:00 +0100 CET

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions