Skip to content

time: time ParseInLocation error #66987

@getaix

Description

@getaix

Go version

go version go1.22.2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/abc/Library/Caches/go-build'
GOENV='/Users/abc/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/abc/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/abc/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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/h6/h_h0rdm91vgfb68pntxflth80000gp/T/go-build3222925675=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

s := "15/04/90 02:00"
fmt.Println(time.ParseInLocation("02/01/06 15:04", s, time.Local))
s = "15/04/90 03:00"
fmt.Println(time.ParseInLocation("02/01/06 15:04", s, time.Local))

What did you see happen?

➜ demo go run main.go
1990-04-15 03:00:00 +0900 CDT
1990-04-15 03:00:00 +0900 CDT


Both 15/04/90 02:00 and 15/04/90 03:00 are parsed as 1990-04-15 03:00:00

What did you expect to see?

➜ demo go run main.go
1990-04-15 02:00:00 +0900 CDT
1990-04-15 03:00:00 +0900 CDT

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.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions