summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-26 16:44:33 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-26 16:44:33 -1000
commit8de1b5cb8915ed9a6e32566431d05fafafeb338d (patch)
tree5a3f6e495537a9a9cab33d5adc6d89cd3cbdc60f /internal/config
parentb4d061cb93d992febb5b70c9d7645afdd3a41890 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go33
1 files changed, 23 insertions, 10 deletions
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