]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.16] time: use offset and isDST when caching zone from extend...
authorIan Lance Taylor <iant@golang.org>
Mon, 5 Apr 2021 19:10:21 +0000 (12:10 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 12 Apr 2021 21:25:46 +0000 (21:25 +0000)
commitf12cf7694f491a13bb39741d183034a917a994b3
tree9b84fe9c6d5ce8abda5ae5815c53dc399ed84fc3
parent9baddd3f21230c55f0ad2a10f5f20579dcf0a0bb
[release-branch.go1.16] time: use offset and isDST when caching zone from extend string

If the current time is computed from extend string
and the zone file contains multiple zones with the
same name, the lookup by name might find incorrect
zone.

This happens for example with the slim Europe/Dublin
time zone file in the embedded zip. This zone file
has last transition in 1996 and rest is covered by
extend string.
tzset returns IST as the zone name to use, but there
are two records with IST name. Lookup by name finds
the wrong one. We need to check offset and isDST too.

In case we can't find an existing zone, we allocate
a new zone so that we use correct offset and isDST.

I have renamed zone variable to zones as it shadowed
the zone type that we need to allocate the cached zone.

Backport note: this change also incorporates portions of
CL 264077.

For #45370
Fixes #45385

Change-Id: If7a0cccc1908e27f0509bf422d824133133250fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/307211
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
src/time/zoneinfo.go
src/time/zoneinfo_read.go
src/time/zoneinfo_test.go