time: enable Location loading from user provided timezone data

The return values of the LoadLocation are inherently dependent
on the runtime environment. Add LoadLocationFromTZData, whose
results depend only on the timezone data provided as arguments.

Fixes #20629

Change-Id: I43b181f4c05c219be3ec57327540263b7cb3b2aa
Reviewed-on: https://go-review.googlesource.com/68890
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Florian Uekermann 2017-10-06 17:16:43 +02:00 committed by Brad Fitzpatrick
parent 9a14cd9e75
commit 2951f909ea
5 changed files with 37 additions and 10 deletions

View file

@ -18,11 +18,11 @@ func initTestingZone() {
localLoc = *z
}
var origZoneSources = zoneSources
var OrigZoneSources = zoneSources
func forceZipFileForTesting(zipOnly bool) {
zoneSources = make([]string, len(origZoneSources))
copy(zoneSources, origZoneSources)
zoneSources = make([]string, len(OrigZoneSources))
copy(zoneSources, OrigZoneSources)
if zipOnly {
zoneSources = zoneSources[len(zoneSources)-1:]
}