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