mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 20:52:15 +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"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -48,6 +49,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if runtime.GOOS == "android" {
|
||||||
|
SetAndroidTZ()
|
||||||
|
}
|
||||||
|
|
||||||
_, _ = maxprocs.Set(maxprocs.Logger(func(string, ...any) {}))
|
_, _ = maxprocs.Set(maxprocs.Logger(func(string, ...any) {}))
|
||||||
if version {
|
if version {
|
||||||
fmt.Printf("Mihomo Meta %s %s %s with %s %s\n",
|
fmt.Printf("Mihomo Meta %s %s %s with %s %s\n",
|
||||||
@ -176,3 +181,15 @@ func updateGeoDatabases() {
|
|||||||
executor.ApplyConfig(cfg, false)
|
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