1
0
mirror of https://github.com/golang/go synced 2024-11-26 00:57:56 -07:00

lib/time, time, time/tzdata: use slim tz data format

Follow-up for CL 261363 which had to retain the fat tz data format due
to failing test.

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.

This slims down zoneinfo.zip (and thus also the embedded copy in
time/tzdata) by ~350KB.

Change-Id: I412f79de98ba45358b8696aca784999b3479135e
Reviewed-on: https://go-review.googlesource.com/c/go/+/261877
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Tobias Klauser 2020-10-13 17:07:34 +02:00 committed by Tobias Klauser
parent fc3a6f4533
commit d83168eb38
5 changed files with 6968 additions and 12977 deletions

View File

@ -21,7 +21,7 @@ curl -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.g
tar xzf tzcode$CODE.tar.gz tar xzf tzcode$CODE.tar.gz
tar xzf tzdata$DATA.tar.gz tar xzf tzdata$DATA.tar.gz
make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo ZFLAGS="-b fat" posix_only make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only
cd zoneinfo cd zoneinfo
rm -f ../../zoneinfo.zip rm -f ../../zoneinfo.zip

Binary file not shown.

View File

@ -10,7 +10,7 @@
// it will use this embedded information. // it will use this embedded information.
// //
// Importing this package will increase the size of a program by about // Importing this package will increase the size of a program by about
// 800 KB. // 450 KB.
// //
// This package should normally be imported by a program's main package, // This package should normally be imported by a program's main package,
// not by a library. Libraries normally shouldn't decide whether to // not by a library. Libraries normally shouldn't decide whether to

File diff suppressed because it is too large Load Diff

View File

@ -325,8 +325,16 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) {
l.cacheEnd = omega l.cacheEnd = omega
if i+1 < len(tx) { if i+1 < len(tx) {
l.cacheEnd = tx[i+1].when 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] l.cacheZone = &l.zone[tx[i].index]
break
} }
} }