]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.14] time: support slim tzdata format
authorIan Lance Taylor <iant@golang.org>
Thu, 22 Oct 2020 22:25:00 +0000 (15:25 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 29 Oct 2020 22:30:04 +0000 (22:30 +0000)
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 #42155

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>
(cherry picked from commit 414668cfbc41fd8cadf74e981849d1e05cc23b2e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/266298
Run-TryBot: Ian Lance Taylor <iant@golang.org>

src/time/zoneinfo_read.go

index 38c40b53d48a551d315923688ca36d30363440e7..b79bd474c7db759fe9e4b27171b737945e98ff05 100644 (file)
@@ -313,8 +313,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
                }
        }