-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c38f08e
commit 38f76dd
Showing
8 changed files
with
64 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//go:build with_quic | ||
|
||
package constant | ||
|
||
const WithQUIC = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//go:build !with_quic | ||
|
||
package constant | ||
|
||
const WithQUIC = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2014 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. | ||
|
||
// kanged from https://github.com/golang/mobile/blob/c713f31d574bb632a93f169b2cc99c9e753fef0e/app/android.go#L89 | ||
|
||
package include | ||
|
||
// #include <time.h> | ||
import "C" | ||
import "time" | ||
|
||
func init() { | ||
var currentT C.time_t | ||
var currentTM C.struct_tm | ||
C.time(¤tT) | ||
C.localtime_r(¤tT, ¤tTM) | ||
tzOffset := int(currentTM.tm_gmtoff) | ||
tz := C.GoString(currentTM.tm_zone) | ||
time.Local = time.FixedZone(tz, tzOffset) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package include | ||
|
||
/* | ||
#cgo CFLAGS: -x objective-c | ||
#cgo LDFLAGS: -framework Foundation | ||
#import <Foundation/Foundation.h> | ||
const char* getSystemTimeZone() { | ||
NSTimeZone *timeZone = [NSTimeZone systemTimeZone]; | ||
NSString *timeZoneName = [timeZone description]; | ||
return [timeZoneName UTF8String]; | ||
} | ||
*/ | ||
import "C" | ||
|
||
import ( | ||
"strings" | ||
"time" | ||
) | ||
|
||
func init() { | ||
tzDescription := C.GoString(C.getSystemTimeZone()) | ||
if len(tzDescription) == 0 { | ||
return | ||
} | ||
location, err := time.LoadLocation(strings.Split(tzDescription, " ")[0]) | ||
if err != nil { | ||
return | ||
} | ||
time.Local = location | ||
} |