summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-26 16:37:25 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-26 16:37:25 -1000
commitb4d061cb93d992febb5b70c9d7645afdd3a41890 (patch)
tree9719f277b1feebf6faa5b2e96cd6bac5af39eb2d
parentb4b663ccb87cbfe7c2bccdca959038e629d09a31 (diff)
Fix Google Calendar timezone handling
- Use event's TimeZone field when parsing DateTime - Handle cases where DateTime has no timezone offset - Parse in event timezone then convert to local for display Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
-rw-r--r--internal/api/google_calendar.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/internal/api/google_calendar.go b/internal/api/google_calendar.go
index dc61f3d..1b1971a 100644
--- a/internal/api/google_calendar.go
+++ b/internal/api/google_calendar.go
@@ -26,11 +26,29 @@ func parseEventTime(item *calendar.Event) (start, end time.Time) {
start, _ = time.ParseInLocation("2006-01-02", item.Start.Date, time.Local)
end, _ = time.ParseInLocation("2006-01-02", item.End.Date, time.Local)
} else {
- // Timed event - parse RFC3339 then convert to local
+ // Timed event - use the event's timezone if specified
+ var loc *time.Location
+ if item.Start.TimeZone != "" {
+ loc, _ = time.LoadLocation(item.Start.TimeZone)
+ }
+ if loc == nil {
+ loc = time.Local
+ }
+
+ // Try parsing with timezone offset first (RFC3339)
start, _ = time.Parse(time.RFC3339, item.Start.DateTime)
end, _ = time.Parse(time.RFC3339, item.End.DateTime)
- start = start.Local()
- end = end.Local()
+
+ // If the parsed time is zero (parse failed) or missing timezone info,
+ // parse in the event's timezone
+ if start.IsZero() || item.Start.DateTime[len(item.Start.DateTime)-1] != 'Z' && !strings.Contains(item.Start.DateTime, "+") && !strings.Contains(item.Start.DateTime, "-") {
+ start, _ = time.ParseInLocation("2006-01-02T15:04:05", item.Start.DateTime, loc)
+ end, _ = time.ParseInLocation("2006-01-02T15:04:05", item.End.DateTime, loc)
+ }
+
+ // Convert to local timezone for display
+ start = start.In(time.Local)
+ end = end.In(time.Local)
}
return
}