-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Please answer these questions before submitting your issue. Thanks!
- What version of Go are you using (
go version)?
go version go1.6.2 windows/amd64 - What operating system and processor architecture are you using (
go env)?
windows 10 x64
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\golang
set GORACE=
set GOROOT=c:\go
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
- What did you do?
package main
import (
"time"
"fmt"
)
func main() {
now :=time.Now()
fmt.Println("now:",now)
fmt.Println("now.Location:",now.Location())
fmt.Println("now.Local().Location:",now.Local().Location())
l,err:=time.LoadLocation(now.Location().String())
fmt.Println(l,err)
l,err=time.LoadLocation(now.Local().Location().String())
fmt.Println(l,err)
}
/*
now: 2016-05-06 09:47:54.1544589 +0800 CST
now.Location:
now.Local().Location:
UTC <nil>
UTC <nil>
*/- What did you expect to see?
Sorry, my English is not good.
now.Location().String() returns "Asia/ShangHai" - What did you see instead?
In non UTC time zone, time.LoadLocation(now.Local().Location().String()) != now.Local().Location()
now.Location() returns ""
now.Local().Location() returns ""
time.LoadLocation(now.Local().Location().String()) returns "UTC"
Is it bug, or is it just like that? I can't get the local time zone.
now.Location().String() returns ""
now.Local().Location().String() returns ""
l, err := time.LoadLocation("Local")
l.String() returns ""
t2, _ := time.Parse("2006-01-02T15:04:05.999999999Z07:00 MST", time.Now().Format("2006-01-02T15:04:05.999999999Z07:00 MST"))
t2.Location() returns ""
t2.Local().Location() returns ""