mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 06:33:14 +08:00
fix: fix timezone for Android
This commit is contained in:
parent
234a4bfc93
commit
cd9e9cd2c1
17
main.go
17
main.go
@ -4,6 +4,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -48,6 +49,10 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if runtime.GOOS == "android" {
|
||||
SetAndroidTZ()
|
||||
}
|
||||
|
||||
_, _ = maxprocs.Set(maxprocs.Logger(func(string, ...any) {}))
|
||||
if version {
|
||||
fmt.Printf("Mihomo Meta %s %s %s with %s %s\n",
|
||||
@ -176,3 +181,15 @@ func updateGeoDatabases() {
|
||||
executor.ApplyConfig(cfg, false)
|
||||
}()
|
||||
}
|
||||
|
||||
func SetAndroidTZ() {
|
||||
out, err := exec.Command("getprop", "persist.sys.timezone").Output()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
z, err := time.LoadLocation(strings.TrimSpace(string(out)))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
time.Local = z
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user