From 8de1b5cb8915ed9a6e32566431d05fafafeb338d Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 26 Jan 2026 16:44:33 -1000 Subject: Fix calendar timezone handling with configurable display timezone - Add TIMEZONE config option (defaults to Pacific/Honolulu) - Store display timezone in GoogleCalendarClient - Convert all event times to configured display timezone - Parse events in their native timezone then convert for display This fixes the issue where events were showing 10 hours off due to server running in UTC while user is in Hawaii. Co-Authored-By: Claude Opus 4.5 --- internal/config/config.go | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'internal/config/config.go') diff --git a/internal/config/config.go b/internal/config/config.go index 62e733a..cf3af49 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -9,10 +9,11 @@ import ( // Config holds all application configuration type Config struct { // API Keys - TodoistAPIKey string - PlanToEatAPIKey string - TrelloAPIKey string - TrelloToken string + TodoistAPIKey string + PlanToEatAPIKey string + PlanToEatSession string // Session cookie for web scraping + TrelloAPIKey string + TrelloToken string // Google Calendar GoogleCredentialsFile string @@ -28,16 +29,20 @@ type Config struct { Port string CacheTTLMinutes int Debug bool + + // Display + Timezone string // IANA timezone name (e.g., "Pacific/Honolulu") } // Load reads configuration from environment variables func Load() (*Config, error) { cfg := &Config{ // API Keys - TodoistAPIKey: os.Getenv("TODOIST_API_KEY"), - PlanToEatAPIKey: os.Getenv("PLANTOEAT_API_KEY"), - TrelloAPIKey: os.Getenv("TRELLO_API_KEY"), - TrelloToken: os.Getenv("TRELLO_TOKEN"), + TodoistAPIKey: os.Getenv("TODOIST_API_KEY"), + PlanToEatAPIKey: os.Getenv("PLANTOEAT_API_KEY"), + PlanToEatSession: os.Getenv("PLANTOEAT_SESSION"), + TrelloAPIKey: os.Getenv("TRELLO_API_KEY"), + TrelloToken: os.Getenv("TRELLO_TOKEN"), // Google Calendar GoogleCredentialsFile: os.Getenv("GOOGLE_CREDENTIALS_FILE"), @@ -53,6 +58,9 @@ func Load() (*Config, error) { Port: getEnvWithDefault("PORT", "8080"), CacheTTLMinutes: getEnvAsInt("CACHE_TTL_MINUTES", 5), Debug: getEnvAsBool("DEBUG", false), + + // Display + Timezone: getEnvWithDefault("TIMEZONE", "Pacific/Honolulu"), } // Validate required fields @@ -81,9 +89,14 @@ func (c *Config) Validate() error { return nil } -// HasPlanToEat checks if PlanToEat is configured +// HasPlanToEat checks if PlanToEat is configured (API key or session) func (c *Config) HasPlanToEat() bool { - return c.PlanToEatAPIKey != "" + return c.PlanToEatAPIKey != "" || c.PlanToEatSession != "" +} + +// HasPlanToEatSession checks if PlanToEat session cookie is configured +func (c *Config) HasPlanToEatSession() bool { + return c.PlanToEatSession != "" } // HasTrello checks if Trello is configured -- cgit v1.2.3