-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
加一个自定义时区的配置 #165
base: master
Are you sure you want to change the base?
加一个自定义时区的配置 #165
Conversation
额,我该rebase到develop branch然后提PR到develop? |
@@ -178,6 +180,12 @@ func UnquoteString(s string) (string, error) { | |||
|
|||
func TimestampFormat(ts int64) string { | |||
t := time.Unix(ts, 0) | |||
if tzStr := config.GlobalConfig.GetString("timezone"); tzStr != "" { | |||
loc, _ := time.LoadLocation(tzStr) |
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.
有些服务器可能没装额外的tzinfo,在这里如果有报错希望能够有日志提醒
另外如果是设置时区的话希望可以全局设置来保持一致性,例如启动读取配置文件后一次性设置下 |
是说连logging之类的其他用到时间戳的地方都保持一致么?我感觉logging的话还是服务器本地时区更方便一些,所以只是对输出的时间戳加了时区变化。 不过只在启动时取一次时区是正确的做法,我看看怎么搞比较方便简洁。 |
部署到外面发现时区出问题了所以...
偷懒直接用了GlobalConfig,如果觉得在util包里直接用config不好的话我改改。