mirror of
https://github.com/jeessy2/ddns-go.git
synced 2024-11-25 16:46:24 +08:00
2c4d8a82f8
* fix: 安卓环境Go Time 固定UTC时区,通过时区获取偏移量修正时区 * fix: 去除tZ参数,只有安卓环境情况下根据getprop persist.sys.timezone 修正时区 --------- Co-authored-by: luo.pengcheng <luo.pengcheng@ikasinfo.com>
20 lines
310 B
Go
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
|
|
}
|