From c3532ec051d0d775ae0f85a60ff6d5d6024c082f Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Sun, 11 Jan 2026 18:27:07 -0700 Subject: [PATCH] inittimezone --- server/main.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/main.go b/server/main.go index c426cb6..bfde82c 100644 --- a/server/main.go +++ b/server/main.go @@ -5,7 +5,9 @@ import ( "fmt" "log" "net/http" + "os" "sync" + "time" ) var ( @@ -37,8 +39,25 @@ func getOrCreateStepManager(userID string) *StepManager { return sm } +func initTimezone() { + tz := os.Getenv("TZ") + if tz != "" { + loc, err := time.LoadLocation(tz) + if err != nil { + log.Printf("Error loading timezone %s: %v. Using UTC.", tz, err) + return + } + time.Local = loc + log.Printf("Timezone set to %s", tz) + } else { + log.Printf("TZ environment variable not set, using system default (usually UTC)") + } + log.Printf("Current system time: %s", time.Now().Format(time.RFC1123Z)) +} + func main() { // Initialize components + initTimezone() InitFitbit() InitUserRegistry() InitVoteRegistry()