-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Description
What version of Go are you using (go version)?
$ go version go version go1.17.2 darwin/amd64
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/freedemon/Library/Caches/go-build" GOENV="/Users/freedemon/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/freedemon/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/freedemon/go" GOPRIVATE="" GOPROXY="https://goproxy.cn" GOROOT="/usr/local/Cellar/go/1.17.2/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.17.2/libexec/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.17.2" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/freedemon/Documents/code/goProject/go2/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/9y/nkxhf5yd3c7fvqdsdvdwm18r0000gn/T/go-build2346662675=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Why are these times incorrect and missed some time ?
package main
import (
"fmt"
"time"
)
func main() {
timeLayout := "2006-01-02 15:04:05"
loc, _ := time.LoadLocation("Asia/Shanghai")
time1, _ := time.ParseInLocation(timeLayout,"1991-09-14 16:50:50", loc)
fmt.Println(time1)
time2, _ := time.ParseInLocation(timeLayout,"1991-09-14 17:00:00", loc)
fmt.Println(time2)
time3, _ := time.ParseInLocation(timeLayout,"1991-09-15 00:50:00", loc)
fmt.Println(time3)
time4, _ := time.ParseInLocation(timeLayout,"1991-09-15 01:00:00", loc)
fmt.Println(time4)
}
What did you expect to see?
1991-09-14 16:50:50 +0900 CDT
1991-09-14 17:00:00 +0900 CDT
1991-09-15 00:50:00 +0900 CDT
1991-09-15 01:00:00 +0800 CST
What did you see instead?
1991-09-14 16:50:50 +0900 CDT
1991-09-14 18:00:00 +0900 CDT
1991-09-15 01:50:00 +0900 CDT
1991-09-15 01:00:00 +0800 CST
James-Xuan
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.