// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.//go:build unix && !ios && !android// Parse "zoneinfo" time zone file.// This is a fairly standard file format used on OS X, Linux, BSD, Sun, and others.// See tzfile(5), https://en.wikipedia.org/wiki/Zoneinfo,// and ftp://munnari.oz.au/pub/oldtz/package timeimport ()// Many systems use /usr/share/zoneinfo, Solaris 2 has// /usr/share/lib/zoneinfo, IRIX 6 has /usr/lib/locale/TZ,// NixOS has /etc/zoneinfo.var platformZoneSources = []string{"/usr/share/zoneinfo/","/usr/share/lib/zoneinfo/","/usr/lib/locale/TZ/","/etc/zoneinfo",}func initLocal() {// consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. , := syscall.Getenv("TZ")switch {case !: , := loadLocation("localtime", []string{"/etc"})if == nil {localLoc = *localLoc.name = "Local"return }case != "":if [0] == ':' { = [1:] }if != "" && [0] == '/' {if , := loadLocation(, []string{""}); == nil {localLoc = *if == "/etc/localtime" {localLoc.name = "Local" } else {localLoc.name = }return } } elseif != "" && != "UTC" {if , := loadLocation(, platformZoneSources); == nil {localLoc = *return } } }// Fall back to UTC.localLoc.name = "UTC"}
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.