Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bybybybyb
Copy link

部署到外面发现时区出问题了所以...
偷懒直接用了GlobalConfig,如果觉得在util包里直接用config不好的话我改改。

@bybybybyb bybybybyb changed the base branch from master to develop August 24, 2022 00:39
@bybybybyb bybybybyb changed the base branch from develop to master August 24, 2022 00:40
@bybybybyb
Copy link
Author

额,我该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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有些服务器可能没装额外的tzinfo,在这里如果有报错希望能够有日志提醒

@Sora233
Copy link
Owner

Sora233 commented Aug 25, 2022

另外如果是设置时区的话希望可以全局设置来保持一致性,例如启动读取配置文件后一次性设置下time.Local

@bybybybyb
Copy link
Author

bybybybyb commented Aug 25, 2022

另外如果是设置时区的话希望可以全局设置来保持一致性,例如启动读取配置文件后一次性设置下time.Local

是说连logging之类的其他用到时间戳的地方都保持一致么?我感觉logging的话还是服务器本地时区更方便一些,所以只是对输出的时间戳加了时区变化。

不过只在启动时取一次时区是正确的做法,我看看怎么搞比较方便简洁。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants