Skip to content

Commit

Permalink
fix: retrieve events in UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Huck committed Sep 10, 2024
1 parent e449ad6 commit 7e7d652
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/adapter/google/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (g *GCalClient) ListEvents(ctx context.Context, starttime time.Time, endtim
TimeMin(starttime.Format(time.RFC3339)).
TimeMax(endtime.Format(time.RFC3339)).
MaxResults(defaultPageMaxResults).
TimeZone("UTC").
OrderBy("startTime").
Context(ctx)

Expand Down
11 changes: 10 additions & 1 deletion internal/adapter/outlook_http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ func (o *OutlookClient) ListEvents(ctx context.Context, start time.Time, end tim
// Otherwise this always ends in a 500 return code, see also https://stackoverflow.com/a/62770941
query := "?startDateTime=" + startDate + "&endDateTime=" + endDate + "&$expand=extensions($filter=Id%20eq%20'inovex.calendarsync.meta')"

resp, err := o.Client.Get(baseUrl + "/me/calendars/" + o.CalendarID + "/CalendarView" + query)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, baseUrl+"/me/calendars/"+o.CalendarID+"/CalendarView"+query, nil)
if err != nil {
return nil, err
}

// Get all the events in UTC timezone
// when we retrieve them from other adapters they will also be in UTC
req.Header.Add("Prefer", "outlook.timezone=\"UTC\"")

resp, err := o.Client.Do(req)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 7e7d652

Please sign in to comment.