github.com/sagernet/sing-box@v1.9.0-rc.20/include/tz_android.go (about)

     1  // Copyright 2014 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  // kanged from https://github.com/golang/mobile/blob/c713f31d574bb632a93f169b2cc99c9e753fef0e/app/android.go#L89
     6  
     7  package include
     8  
     9  // #include <time.h>
    10  import "C"
    11  import "time"
    12  
    13  func init() {
    14  	var currentT C.time_t
    15  	var currentTM C.struct_tm
    16  	C.time(&currentT)
    17  	C.localtime_r(&currentT, &currentTM)
    18  	tzOffset := int(currentTM.tm_gmtoff)
    19  	tz := C.GoString(currentTM.tm_zone)
    20  	time.Local = time.FixedZone(tz, tzOffset)
    21  }