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
7package time
8
9import (
10	"syscall"
11)
12
13var platformZoneSources []string // none on iOS
14
15func gorootZoneSource(goroot string) (string, bool) {
16	// The working directory at initialization is the root of the
17	// app bundle: "/private/.../bundlename.app". That's where we
18	// keep zoneinfo.zip for tethered iOS builds.
19	// For self-hosted iOS builds, the zoneinfo.zip is in GOROOT.
20	var roots []string
21	if goroot != "" {
22		roots = append(roots, goroot+"/lib/time")
23	}
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 + "/zoneinfo.zip", true
37		}
38	}
39	return "", false
40}
41
42func initLocal() {
43	// TODO(crawshaw): [NSTimeZone localTimeZone]
44	localLoc = *UTC
45}
46