ddns-go/util/andriod_time.go
luopc 2c4d8a82f8
Some checks failed
test / test (amd64) (push) Has been cancelled
test / test (arm64) (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
fix: 安卓环境Go Time 固定UTC时区,通过时区获取偏移量修正时区 (#1284)
* fix: 安卓环境Go Time 固定UTC时区,通过时区获取偏移量修正时区

* fix: 去除tZ参数,只有安卓环境情况下根据getprop persist.sys.timezone 修正时区

---------

Co-authored-by: luo.pengcheng <luo.pengcheng@ikasinfo.com>
2024-10-17 18:25:24 +08:00

20 lines
310 B
Go

package util
import (
"os/exec"
"strings"
"time"
)
func FixTimezone() {
out, err := exec.Command("/system/bin/getprop", "persist.sys.timezone").Output()
if err != nil {
return
}
timeZone, err := time.LoadLocation(strings.TrimSpace(string(out)))
if err != nil {
return
}
time.Local = timeZone
}