-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 安卓环境Go Time 固定UTC时区,通过时区获取偏移量修正时区 #1284
Conversation
根据你的提示已经做了修改, tZ 参数不设置默认值, 根据环境获取时区字符串, 传入 tZ 则用自定义的时区 |
main.go
Outdated
// 修正安卓时区 | ||
var timeZone = flag.String("tZ", "", "fix Android Time Zone") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只有android才有问题吧,可以不要此参数,判断是android才自动改。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的目前发现只有安卓会出现这个问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只有android才有问题吧,可以不要此参数,判断是android才自动改。
加入参数是为了,让用户可以自定义选择时区
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那可以不用这个参数,简单点
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那可以不用这个参数,简单点
好的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
判断是android,直接用那段代码,不搞复杂了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
判断是android,直接用那段代码,不搞复杂了
已做修改
main.go
Outdated
// func initLocal() { | ||
// // TODO(elias.naur): getprop persist.sys.timezone | ||
// localLoc = *UTC | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段也不要了吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已去除,希望能加入
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测了正常吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修复安卓环境运行ddns-go 少8小时的问题。
[go/src/time/zoneinfo_android.go]
func initLocal() {
// TODO(elias.naur): getprop persist.sys.timezone
localLoc = *UTC
}
zoneinfo_android.go 固定了 localLoc 为 UTC,所以设置环境变量无效。
设置启动参数 tZ, 默认从环境获取时区字符串, 判断当前GOOS为 android 调用 FixTimezone 进行时区修正