-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Hi,
I have create time.Time for 1986-05-04 using time.Date(), and then use Zone() or Format to display it...
but for 1986-05-04, timeZone will be CDT +09:00, not my Local time in China(+08:00), but for 2017-08-01 it works well...
I try to read code in time.Date(), it will do some adjust when time second too close to a zone transition...so it first get CDT then adjust to CST, but haven't found that in other time.lookup() usage, and they return CDT directly, what about this?- -
- What version of Go are you using (
go version)?
go1.6.2
- What operating system and processor architecture are you using (
go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/didi/Code/go:/Users/didi/.gvm/pkgsets/go1.6.2/global"
GORACE=""
GOROOT="/Users/didi/.gvm/gos/go1.6.2"
GOTOOLDIR="/Users/didi/.gvm/gos/go1.6.2/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
and I'm in China.. CST +08:00
- What did you do?
run a simple main.go
package main
import (
"fmt"
"time"
)
func main() {
tt := time.Date(1986, 5, 4, 0, 0, 0, 0, time.Local)
z, offset := tt.Zone()
fmt.Println(z, offset, tt.Format(time.RFC3339))
tt = time.Date(2016, 8, 1, 0, 0, 0, 0, time.Local)
z, offset = tt.Zone()
fmt.Println(z, offset, tt.Format(time.RFC3339))
}
-
What did you expect to see?
CST 28800 1986-05-04T00:00:00+08:00
CST 28800 2016-08-01T00:00:00+08:00 -
What did you see instead?
CDT 32400 1986-05-04T01:00:00+09:00
CST 28800 2016-08-01T00:00:00+08:00