-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Go version
go version go1.23.0 darwin/arm64
Output of go env in your module/workspace:
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/dtextores/Library/Caches/go-build'
GOENV='/Users/dtextores/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/dtextores/go/pkg/mod'
GONOPROXY='redacted'
GONOSUMDB='redacted'
GOOS='darwin'
GOPATH='/Users/dtextores/go'
GOPRIVATE='redacted'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/dtextores/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/dtextores/code/redacted/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/0g/tnsylx9n7qn2m0j4gmp452gh0000gn/T/go-build1406944028=/tmp/go-build -gno-record-gcc-switches -fno-common'What did you do?
package main
import (
"fmt"
"time"
)
func main() {
tz, offset := time.Now().Zone()
fmt.Printf("tz: %s, offset: %d", tz, offset)
loc, err := time.LoadLocation(tz)
fmt.Printf("loc: %s, err: %s", loc, err)
}I'm in the Europe/Berlin Timezone, where the daylight savings time is called "CEST" as reported by time.Now().Zone(). I also tested with Europe/Bucharest ("EEST").
https://go.dev/play/p/_RHfB4rcJzi
What did you see happen?
Running the code right now during daylight savings time yields:
tz: CEST, offset: 7200loc: UTC, err: unknown time zone CEST. (Please excuse the formatting here, I threw this together quickly.)
Running it with the clock set to March 1, and timezone updated to CET accordingly yields:
tz: CET, offset: 3600loc: CET, err: %!s(<nil>)
What did you expect to see?
I should always be able to load a location from a timezone string obtained by time.Now().Zone() during Daylight Savings Time the same as during Winter Time. In other words, I would expect the first result to be something like:
tz: CEST, offset: 7200loc: CEST, err: %!s(<nil>)