]> Cypherpunks repositories - gostls13.git/commitdiff
time: zoneinfo support on darwin/arm
authorDavid Crawshaw <crawshaw@golang.org>
Mon, 2 Mar 2015 21:01:20 +0000 (16:01 -0500)
committerDavid Crawshaw <crawshaw@golang.org>
Tue, 3 Mar 2015 02:24:34 +0000 (02:24 +0000)
A future change will include an NSTimeZone hook so we can determine
the device's current time zone.

Change-Id: Ia4bd6b955e4cb720c518055541b66ff57a4dd303
Reviewed-on: https://go-review.googlesource.com/6511
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>

src/time/sleep_test.go
src/time/zoneinfo_darwin_armx.go [new file with mode: 0644]
src/time/zoneinfo_unix.go

index c9b2956b7845e58e1d5bf0c766bade121ce3a8c6..6452a9e0274753c83a5010d1803a001ed1344805 100644 (file)
@@ -383,6 +383,10 @@ func TestOverflowSleep(t *testing.T) {
 // Test that a panic while deleting a timer does not leave
 // the timers mutex held, deadlocking a ticker.Stop in a defer.
 func TestIssue5745(t *testing.T) {
+       if runtime.GOOS == "darwin" && runtime.GOARCH == "arm" {
+               t.Skipf("skipping on %s/%s, see issue 10043", runtime.GOOS, runtime.GOARCH)
+       }
+
        ticker := NewTicker(Hour)
        defer func() {
                // would deadlock here before the fix due to
diff --git a/src/time/zoneinfo_darwin_armx.go b/src/time/zoneinfo_darwin_armx.go
new file mode 100644 (file)
index 0000000..f09166c
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright 2015 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.
+
+// +build darwin
+// +build arm arm64
+
+package time
+
+import "syscall"
+
+var zoneFile string
+
+func init() {
+       wd, err := syscall.Getwd()
+       if err != nil {
+               return
+       }
+
+       // The working directory at initialization is the root of the
+       // app bundle: "/private/.../bundlename.app". That's where we
+       // keep zoneinfo.zip.
+       zoneFile = wd + "/zoneinfo.zip"
+}
+
+func forceZipFileForTesting(zipOnly bool) {
+       // On iOS we only have the zip file.
+}
+
+func initTestingZone() {
+       z, err := loadZoneFile(zoneFile, "America/Los_Angeles")
+       if err != nil {
+               panic("cannot load America/Los_Angeles for testing: " + err.Error())
+       }
+       z.name = "Local"
+       localLoc = *z
+}
+
+func initLocal() {
+       // TODO(crawshaw): [NSTimeZone localTimeZone]
+       localLoc = *UTC
+}
+
+func loadLocation(name string) (*Location, error) {
+       z, err := loadZoneFile(zoneFile, name)
+       if err != nil {
+               return nil, err
+       }
+       z.name = name
+       return z, nil
+}
index 66540969d587a7abd8897c25f8d1ae6e3b339dcd..687d0046687a9357ed9f90b1f59ca25182bb428e 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin,!arm,!arm64 dragonfly freebsd linux nacl netbsd openbsd solaris
 
 // Parse "zoneinfo" time zone file.
 // This is a fairly standard file format used on OS X, Linux, BSD, Sun, and others.