1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 var zoneSources
= []string{
15 "/usr/share/zoneinfo/",
16 "/usr/share/lib/zoneinfo/",
17 "/usr/lib/locale/TZ/",
18 runtime
.GOROOT() + "/lib/time/zoneinfo.zip",
22 localLoc
.name
= "Local"
25 d
:= js
.Global().Get("Date").New()
26 offset
:= d
.Call("getTimezoneOffset").Int() * -1
27 z
.offset
= offset
* 60
28 // According to https://tc39.github.io/ecma262/#sec-timezoneestring,
29 // the timezone name from (new Date()).toTimeString() is an implementation-dependent
30 // result, and in Google Chrome, it gives the fully expanded name rather than
32 // Hence, we construct the name from the offset.
40 z
.name
+= itoa(offset
/ 60)
43 z
.name
+= ":" + itoa(min
)
45 localLoc
.zone
= []zone
{z
}
48 // itoa is like strconv.Itoa but only works for values of i in range [0,99].
49 // It panics if i is out of range.
50 func itoa(i
int) string {
52 return digits
[i
: i
+1]
54 return smallsString
[i
*2 : i
*2+2]
57 const smallsString
= "00010203040506070809" +
58 "10111213141516171819" +
59 "20212223242526272829" +
60 "30313233343536373839" +
61 "40414243444546474849" +
62 "50515253545556575859" +
63 "60616263646566676869" +
64 "70717273747576777879" +
65 "80818283848586878889" +
66 "90919293949596979899"
67 const digits
= "0123456789"