Skip to content

time: Date returns a Time object with incorrect offset for years 1900-1905 #30099

@jinfengnarvar

Description

@jinfengnarvar

What version of Go are you using (go version)?

$ go version
go version go1.11.2 darwin/amd64

Does this issue reproduce with the latest release?

Don't know. I did repro this issue on https://play.golang.org/.

What operating system and processor architecture are you using (go env)?

$ go env
GOARCH="amd64"
GOBIN="/Users/jinfeng/dev/narvar/go/bin"
GOCACHE="/Users/jinfeng/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jinfeng/dev/narvar/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/x2/6yhw9qq129gffvpx90dv5gyw0000gp/T/go-build291093703=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Here is the repro code:

package main

import (
	"fmt"
	"time"
)

func main() {
	for i := 1900; i <= 1910; i++ {
		//tz := "Asia/Calcutta"
		tz := "America/New_York"
		loc, err := time.LoadLocation(tz)
		if err != nil {
			fmt.Println(i, "/", err)
			return
		}
		t := time.Date(i, time.January, 1, 0, 0, 0, 0, loc)
		tstr := t.Format(time.RFC3339)
		tzName, tzOffset := t.Zone()
		fmt.Println(tstr, "/", tzName, "/", tzOffset)
	}
}

What did you expect to see?

1900-01-01T00:00:00-05:00 / EST / -18000
1901-01-01T00:00:00-05:00 / EST / -18000
1902-01-01T00:00:00-05:00 / EST / -18000
1903-01-01T00:00:00-05:00 / EST / -18000
1904-01-01T00:00:00-05:00 / EST / -18000
1905-01-01T00:00:00-05:00 / EST / -18000
1906-01-01T00:00:00-05:00 / EST / -18000
1907-01-01T00:00:00-05:00 / EST / -18000
1908-01-01T00:00:00-05:00 / EST / -18000
1909-01-01T00:00:00-05:00 / EST / -18000
1910-01-01T00:00:00-05:00 / EST / -18000

What did you see instead?

1900-01-01T00:00:00-04:56 / LMT / -17762
1901-01-01T00:00:00-04:56 / LMT / -17762
1902-01-01T00:00:00-05:00 / EST / -18000
1903-01-01T00:00:00-05:00 / EST / -18000
1904-01-01T00:00:00-05:00 / EST / -18000
1905-01-01T00:00:00-05:00 / EST / -18000
1906-01-01T00:00:00-05:00 / EST / -18000
1907-01-01T00:00:00-05:00 / EST / -18000
1908-01-01T00:00:00-05:00 / EST / -18000
1909-01-01T00:00:00-05:00 / EST / -18000
1910-01-01T00:00:00-05:00 / EST / -18000

Similar output for "Asia/Calcutta" time zone, except the deviation lasts through 1905:

1900-01-01T00:00:00+05:53 / HMT / 21200
1901-01-01T00:00:00+05:53 / HMT / 21200
1902-01-01T00:00:00+05:21 / MMT / 19270
1903-01-01T00:00:00+05:21 / MMT / 19270
1904-01-01T00:00:00+05:21 / MMT / 19270
1905-01-01T00:00:00+05:21 / MMT / 19270
1906-01-01T00:08:50+05:30 / IST / 19800
1907-01-01T00:00:00+05:30 / IST / 19800
1908-01-01T00:00:00+05:30 / IST / 19800
1909-01-01T00:00:00+05:30 / IST / 19800
1910-01-01T00:00:00+05:30 / IST / 19800

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions