Fix CentralTime init order (again)

This commit is contained in:
2023-12-26 08:07:09 -06:00
parent 14295d1264
commit 44d5e533f3
2 changed files with 8 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"time" "time"
_ "time/tzdata"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/joho/godotenv" "github.com/joho/godotenv"
@@ -26,11 +27,18 @@ var (
isDevelopment bool isDevelopment bool
baseURL string // Base URL for all requests to the banner system baseURL string // Base URL for all requests to the banner system
environment string environment string
CentralTime *time.Location
) )
func init() { func init() {
ctx = context.Background() ctx = context.Background()
var err error
CentralTime, err = time.LoadLocation("America/Chicago")
if err != nil {
panic(err)
}
// Set zerolog's timestamp function to use the central timezone // Set zerolog's timestamp function to use the central timezone
zerolog.TimestampFunc = func() time.Time { zerolog.TimestampFunc = func() time.Time {
return time.Now().In(CentralTime) return time.Now().In(CentralTime)

View File

@@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"time" "time"
_ "time/tzdata"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )
@@ -27,16 +26,9 @@ type Term struct {
var ( var (
SpringRange, SummerRange, FallRange YearDayRange SpringRange, SummerRange, FallRange YearDayRange
CentralTime *time.Location
) )
func init() { func init() {
var err error
CentralTime, err = time.LoadLocation("America/Chicago")
if err != nil {
panic(err)
}
SpringRange, SummerRange, FallRange = GetYearDayRange(uint16(time.Now().Year())) SpringRange, SummerRange, FallRange = GetYearDayRange(uint16(time.Now().Year()))
currentTerm, nextTerm := GetCurrentTerm(time.Now()) currentTerm, nextTerm := GetCurrentTerm(time.Now())