Black Lives Matter. Support the Equal Justice Initiative.

Source file src/time/zoneinfo_ios.go

Documentation: time

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

View as plain text