mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-02 20:57:38 +03:00
Android: use getprop persist.sys.timezone to get and set the time zone
Untested. Maybe fixes #1351
This commit is contained in:
parent
9d1eee4b29
commit
b0e883ebc6
3 changed files with 28 additions and 0 deletions
|
@ -27,6 +27,7 @@ type App struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
TimezoneSetup()
|
||||
dlog.Init("dnscrypt-proxy", dlog.SeverityNotice, "DAEMON")
|
||||
|
||||
seed := make([]byte, 8)
|
||||
|
|
20
dnscrypt-proxy/timezone_android.go
Normal file
20
dnscrypt-proxy/timezone_android.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TimezoneSetup() error {
|
||||
out, err := exec.Command("/system/bin/getprop", "persist.sys.timezone").Output()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
z, err := time.LoadLocation(strings.TrimSpace(string(out)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
time.Local = z
|
||||
return nil
|
||||
}
|
7
dnscrypt-proxy/timezone_others.go
Normal file
7
dnscrypt-proxy/timezone_others.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
// +build !android
|
||||
|
||||
package main
|
||||
|
||||
func TimezoneSetup() error {
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue