inovex / CalendarSync

Stateless CLI tool to sync calendars across different calendaring systems.
MIT License
99 stars 13 forks source link

Synced Timezone wrong #168

Open Trefex opened 2 months ago

Trefex commented 2 months ago

Hi,

In my source, events are at 1 PM, but in the sink, they will be synced as 11 AM.

Are timezones perhaps not handled correctly or is it something i missed in a config?

Thanks T

alxndr13 commented 1 month ago

Hey! Thanks for the bug report! (and sorry for the late response!)

Could you give me some more details? Are you using different timezone's in both calendars?

Trefex commented 1 month ago

Hey! Thanks for the bug report! (and sorry for the late response!)

Could you give me some more details? Are you using different timezone's in both calendars?

I basically sync to the same account in a different calendar for testing, so i guess the timezones are the same?

Trefex commented 4 weeks ago

@alxndr13 is it possible that for the Outlook to Outlook use case, timezone is not handled properly ?

https://github.com/inovex/CalendarSync/blob/main/internal/adapter/outlook_http/client.go#L275

alxndr13 commented 1 day ago

@Trefex i just found the time to dig deeper into this.

Thanks for the bug report again! We definitely aren't handling timezones the way we should. I tested this as follows:

Created an event in my outlook source and made sure to use a different timezone. (Asia/Tomsk)

The event will then be represented in the API Response in UTC[1], the only fields which would cover the timezone correctly is the originalStartTimeZone and originalEndTimeZone[2]. The DateTimeTimeZone field just has the timezone set to UTC, which seems counterintuitive.

[1]: screenshot 2024-09-04 at 19 11 25

[2]: screenshot 2024-09-04 at 19 10 53

This is also why it is working all the time for my case, where i have outlook as the sink: i just retrieve the UTC Time and write it in UTC to my google sink. The clients then represent the events according to my machines timezone.

In case we use outlook as a sink, we should make sure to convert (and set) the timezone to UTC when retrieving events. Your local client should then show the time according to your preferred timezone.

Need to attend a padel match now, will have a deeper look at this in the coming days i hope.