diff --git a/config.go b/config.go index 821cb23d4542de6f1abf6b26e72bfacf03ecf72d..09e0b3e89fd53601ffdba130e17255432b58e823 100644 --- a/config.go +++ b/config.go @@ -6,11 +6,13 @@ import ( "log" "os" "strconv" + "time" ) var ( administrators map[string]bool guildID string + timezone *time.Location ) type conf struct { @@ -30,8 +32,9 @@ type serverConf struct { } type systemConf struct { - Verbose bool `toml:"verbose"` - Store string `toml:"store"` + Verbose bool `toml:"verbose"` + Store string `toml:"store"` + Timezone string `toml:"timezone"` } type discordConf struct { @@ -77,6 +80,12 @@ func confLoad() { } } + if location, err := time.LoadLocation(config.System.Timezone); err != nil { + log.Fatalf("error parsing location: %s", err) + } else { + timezone = location + } + if len(config.Discord.Administrators) != 0 && config.Discord.Administrators[0] != -1 { administrators = make(map[string]bool) @@ -92,8 +101,9 @@ func confLoad() { var defConf = conf{ System: systemConf{ - Verbose: false, - Store: "db", + Verbose: false, + Store: "db", + Timezone: "UTC", }, Server: serverConf{ Host: "127.0.0.1", diff --git a/tournament.go b/tournament.go index c3bb0c4a88e8ee5f2596a1fb730661e8f1775f97..1350a1c6d77c5486ffe22cbf0d0b5fdc10cf471b 100644 --- a/tournament.go +++ b/tournament.go @@ -69,7 +69,7 @@ func parseDate(date string) time.Time { d[i] = n } } - return time.Date(d[0], time.Month(d[1]), d[2], 0, 0, 0, 0, time.Local) + return time.Date(d[0], time.Month(d[1]), d[2], 0, 0, 0, 0, timezone) } var tournamentLock = sync.RWMutex{}