-
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.
Milestone
Description
What version of Go are you using (go version)?
go version go1.15.1 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
go env Output
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/marko/.cache/go-build" GOENV="/home/marko/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/marko/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/marko/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" 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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build275905408=/tmp/go-build -gno-record-gcc-switches"
What did you do?
func main() {
loc, _ := time.LoadLocation("America/Santiago")
var t0, t1 time.Time
t0 = time.Date(2020, 9, 3, 0, 0, 0, 0, loc)
for i := 0; i < 5; i++ {
t1 = t0.AddDate(0, 0, 1) // Note that I'm always adding 1 day
y, m, d := t1.Date()
fmt.Printf("midnight=[%v] day duration=%v date=%02d-%02d-%02d\n", t1, t1.Sub(t0), y, m, d)
t0 = t1
}
}
https://play.golang.org/p/F0pGumkcKVb
What did you expect to see?
All days except one are 24h. The day on which DST is introduced should be 23h long.
What did you see instead?
In the loop I'm always adding one day. But Chile started using DST on 6 September (at midnight!). And weirdly there are two days that are 23h long.
midnight=[2020-09-04 00:00:00 -0400 -04] day duration=24h0m0s date=2020-09-04 midnight=[2020-09-05 00:00:00 -0400 -04] day duration=24h0m0s date=2020-09-05 midnight=[2020-09-05 23:00:00 -0400 -04] day duration=23h0m0s date=2020-09-05 midnight=[2020-09-06 23:00:00 -0300 -03] day duration=23h0m0s date=2020-09-06 midnight=[2020-09-07 23:00:00 -0300 -03] day duration=24h0m0s date=2020-09-07
The root of the problem is probably that time.Date(2020, 9, 6, 0, 0, 0, 0, loc@"America/Santiago") returns 2020-09-05 23:00:00 -04 rather than 2020-09-06 00:00:00 -03.
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.