-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 安卓环境Go Time 固定UTC时区,通过时区获取偏移量修正时区 (#1284)
* fix: 安卓环境Go Time 固定UTC时区,通过时区获取偏移量修正时区 * fix: 去除tZ参数,只有安卓环境情况下根据getprop persist.sys.timezone 修正时区 --------- Co-authored-by: luo.pengcheng <[email protected]>
- Loading branch information
1 parent
e99ab31
commit 2c4d8a8
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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 | ||
} |