From 4e966a28796cfffc5ff5cb7616853e4e014f9c2b Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Thu, 14 Jul 2022 15:55:36 +0800 Subject: [PATCH] add timezone config for dtmsvr --- conf.sample.yml | 1 + dtmsvr/config/config.go | 1 + dtmsvr/entry/main.go | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/conf.sample.yml b/conf.sample.yml index f0f2cb6..fb74f14 100644 --- a/conf.sample.yml +++ b/conf.sample.yml @@ -68,3 +68,4 @@ ### advanced options # UpdateBranchAsyncGoroutineNum: 1 # num of async goroutine to update branch status +# TimeZoneOffset: '' #default '' using system default. '+8': Asia/Shanghai; '0': GMT \ No newline at end of file diff --git a/dtmsvr/config/config.go b/dtmsvr/config/config.go index c3e7546..7a0e1a7 100644 --- a/dtmsvr/config/config.go +++ b/dtmsvr/config/config.go @@ -95,6 +95,7 @@ type Type struct { UpdateBranchAsyncGoroutineNum int64 `yaml:"UpdateBranchAsyncGoroutineNum" default:"1"` LogLevel string `yaml:"LogLevel" default:"info"` Log Log `yaml:"Log"` + TimeZoneOffset string `yaml:"TimeZoneOffset"` } // Config config diff --git a/dtmsvr/entry/main.go b/dtmsvr/entry/main.go index 758fa82..df91118 100644 --- a/dtmsvr/entry/main.go +++ b/dtmsvr/entry/main.go @@ -5,7 +5,9 @@ import ( "fmt" "os" "path/filepath" + "time" + "github.com/dtm-labs/dtm/client/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/logger" "github.com/dtm-labs/dtm/dtmsvr" "github.com/dtm-labs/dtm/dtmsvr/config" @@ -43,6 +45,9 @@ func Main(version *string) (*gin.Engine, *config.Type) { } logger.Infof("dtm version is: %s", *version) config.MustLoadConfig(*confFile) + if config.Config.TimeZoneOffset != "" { + time.Local = time.FixedZone("UTC", dtmimp.MustAtoi(config.Config.TimeZoneOffset)*3600) + } conf := &config.Config if *isDebug { conf.LogLevel = "debug"