diff --git a/main.go b/main.go index 748fa2e30..4b2dff9c3 100644 --- a/main.go +++ b/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 +}