github.com/AESNooper/go/src@v0.0.0-20220218095104-b56a4ab1bbbb/time/zoneinfo_ios.go (about) 1 // Copyright 2015 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. 4 5 //go:build ios 6 7 package time 8 9 import ( 10 "runtime" 11 "syscall" 12 ) 13 14 var zoneSources = []string{ 15 getZoneRoot() + "/zoneinfo.zip", 16 } 17 18 func getZoneRoot() string { 19 // The working directory at initialization is the root of the 20 // app bundle: "/private/.../bundlename.app". That's where we 21 // keep zoneinfo.zip for tethered iOS builds. 22 // For self-hosted iOS builds, the zoneinfo.zip is in GOROOT. 23 roots := []string{runtime.GOROOT() + "/lib/time"} 24 wd, err := syscall.Getwd() 25 if err == nil { 26 roots = append(roots, wd) 27 } 28 for _, r := range roots { 29 var st syscall.Stat_t 30 fd, err := syscall.Open(r, syscall.O_RDONLY, 0) 31 if err != nil { 32 continue 33 } 34 defer syscall.Close(fd) 35 if err := syscall.Fstat(fd, &st); err == nil { 36 return r 37 } 38 } 39 return "/XXXNOEXIST" 40 } 41 42 func initLocal() { 43 // TODO(crawshaw): [NSTimeZone localTimeZone] 44 localLoc = *UTC 45 }