summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-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
}