mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-14 12:53:17 +00:00
31 lines
583 B
Go
31 lines
583 B
Go
|
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
|
||
|
}
|