elementary / calendar

Desktop calendar app designed for elementary OS
https://elementary.io
GNU General Public License v3.0
130 stars 39 forks source link

Do all timezone calculations in libical #709

Closed mcclurgm closed 2 years ago

mcclurgm commented 2 years ago

Fixes #572, possibly others

As discussed in #660, the conversion process from libical to GLib timezones is very brittle. The most visible result is that Windows-style timezones (Western European Standard Time) are not handled.

This PR moves all timezone logic to libical, which should have access to all the necessary information to run timezone conversions properly, regardless of whether the timezone corresponds to a system built-in. I accomplished this by modifying the functions that convert ICal.Time and ICal.Component to GLib.DateTime.

Basically, the change in this PR is converting the timezone in libical before calling icaltime_to_datetime, instead of converting after in GLib. That's the only subtantive change, really.

One restriction is that some of thsee convert to DateTimes in non-local timezones. Since it's not always possible to get a GLib.TimeZone for these cases, the timezone in resulting DateTimes isn't guaranteed to be correct. I documented this restriction with emphasis, but it's still not ideal.

I added lots of tests to make sure this works as intended. So I'm pretty sure the new/modified functions all work properly, but the question is if there are any clients that need to be fixed. A text search for function calls didn't reveal anything, but in review I'd appreciate some help looking. If there are no weird cases I missed, then the modified functions should be a drop-in replacement.

Sorry for the terrible commit history. It includes some duplicate work from #653. I'd recommend looking at only the changed files for review, and committing using squash for sure.

danirabbit commented 2 years ago

Thanks for all of your work on this!