Source file
src/time/zoneinfo_unix.go
1
2
3
4
5
6
7
8
9
10
11
12 package time
13
14 import (
15 "runtime"
16 "syscall"
17 )
18
19
20
21 var zoneSources = []string{
22 "/usr/share/zoneinfo/",
23 "/usr/share/lib/zoneinfo/",
24 "/usr/lib/locale/TZ/",
25 runtime.GOROOT() + "/lib/time/zoneinfo.zip",
26 }
27
28 func initLocal() {
29
30
31
32
33
34
35
36 tz, ok := syscall.Getenv("TZ")
37 switch {
38 case !ok:
39 z, err := loadLocation("localtime", []string{"/etc"})
40 if err == nil {
41 localLoc = *z
42 localLoc.name = "Local"
43 return
44 }
45 case tz != "":
46 if tz[0] == ':' {
47 tz = tz[1:]
48 }
49 if tz != "" && tz[0] == '/' {
50 if z, err := loadLocation(tz, []string{""}); err == nil {
51 localLoc = *z
52 if tz == "/etc/localtime" {
53 localLoc.name = "Local"
54 } else {
55 localLoc.name = tz
56 }
57 return
58 }
59 } else if tz != "" && tz != "UTC" {
60 if z, err := loadLocation(tz, zoneSources); err == nil {
61 localLoc = *z
62 return
63 }
64 }
65 }
66
67
68 localLoc.name = "UTC"
69 }
70
View as plain text