diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-10-22 15:25:00 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-10-29 19:02:27 +0000 |
commit | 414668cfbc41fd8cadf74e981849d1e05cc23b2e (patch) | |
tree | 831e3072794543cec537b3962c9a2a5a2b69e4dd | |
parent | 777e455106b784b49bf0fe969bcdf802a1104026 (diff) | |
download | go-414668cfbc41fd8cadf74e981849d1e05cc23b2e.tar.gz go-414668cfbc41fd8cadf74e981849d1e05cc23b2e.zip |
[release-branch.go1.15] time: support slim tzdata format
Backport of part of https://golang.org/cl/261877 to support the slim
tzdata format. As of tzdata 2020b, the default is to use the slim format.
We need to support that format so that Go installations continue to
work when tzdata is updated.
Relevant part of the CL description:
The reason for the failed tests was that when caching location data, the
extended time format past the end of zone transitions was not
considered. The respective change was introduced in (*Location).lookup
by CL 215539.
For #42138
Change-Id: I37f52a0917b2c6e3957e6b4612c8ef104c736e65
Reviewed-on: https://go-review.googlesource.com/c/go/+/264301
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
-rw-r--r-- | src/time/zoneinfo_read.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/time/zoneinfo_read.go b/src/time/zoneinfo_read.go index 6f789be92a..e9f1ab2ec6 100644 --- a/src/time/zoneinfo_read.go +++ b/src/time/zoneinfo_read.go @@ -325,8 +325,16 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { l.cacheEnd = omega if i+1 < len(tx) { l.cacheEnd = tx[i+1].when + } else if l.extend != "" { + // If we're at the end of the known zone transitions, + // try the extend string. + if _, _, estart, eend, ok := tzset(l.extend, l.cacheEnd, sec); ok { + l.cacheStart = estart + l.cacheEnd = eend + } } l.cacheZone = &l.zone[tx[i].index] + break } } |