time: reduce OS dependent timezone related code

Loading and testing timezones is currently implemented using several,
partly redundant, OS specific data structures and functions. This
change merges most of that code into OS independent implementations.

Change-Id: Iae2877c5f48d1e4a9de9ce55d0530d52e24cf96e
Reviewed-on: https://go-review.googlesource.com/64391
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Florian Uekermann 2017-09-18 19:22:29 +02:00 committed by Ian Lance Taylor
parent abd7ba026d
commit 7340d13977
12 changed files with 116 additions and 182 deletions

View file

@ -9,6 +9,25 @@ func init() {
ForceUSPacificForTesting()
}
func initTestingZone() {
z, err := loadLocation("America/Los_Angeles", zoneSources[len(zoneSources)-1:])
if err != nil {
panic("cannot load America/Los_Angeles for testing: " + err.Error())
}
z.name = "Local"
localLoc = *z
}
var origZoneSources = zoneSources
func forceZipFileForTesting(zipOnly bool) {
zoneSources = make([]string, len(origZoneSources))
copy(zoneSources, origZoneSources)
if zipOnly {
zoneSources = zoneSources[len(zoneSources)-1:]
}
}
var Interrupt = interrupt
var DaysIn = daysIn