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