Skip to content

time: TZ=UTC does not cause Location field to be nil #19202

@pzinovkin

Description

@pzinovkin

What did you do?

package main

import (
	"fmt"
	"os"
	"time"
)

func main() {
	fmt.Println("TZ:", os.Getenv("TZ"))
	fmt.Printf("%#v\n", time.Now())
	fmt.Printf("%#v\n", time.Now().UTC())
}
bash-3.2$ TZ="UTC" go run tt.go
TZ: UTC
time.Time{sec:63623205117, nsec:63974400, loc:(*time.Location)(0x110e4e0)}
time.Time{sec:63623205117, nsec:64010002, loc:(*time.Location)(nil)}

What did you expect to see?

Both strings to contain nil Location.

System details

go version go1.8 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/pzinovkin"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.8/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.8/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/fv/0mdc02116kn485ml31tvs26w0000gn/T/go-build085816660=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
GOROOT/bin/go version: go version go1.8 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.8 X:framepointer
uname -v: Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.3
BuildVersion:	16D32
lldb --version: lldb-360.1.70

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions