[mkcal] Properly detect all day for stored events with a time zone. Contributes to JB#43311
All day event detection from storage was done by converting start end end date time into local time and check that both were set at QTime(). This suppose that all day incidences are always stored in local time, which is not enforced by the modifyComponents() function.
Instead of enforcing this constraint, this commit base the all day detection in selectComponents() on local time when the event has been stored without time zone (current behaviour) but on the stored local time when the event has a time zone.
The existing test for instance was setting up a all day event in UTC time zone (see alldayUtc test case). There was no check on fetchedEvent to be all day, adding it makes the test fails, demonstrating the issue. Moreover, since the fetched event is not detected as all day, the end date is shifted one day and the last QCOMPARE requires to do (endDate == startDate.addDays(1)), while it should not do this. See the allday() set of tests for instance. So in my opinion, this behaviour is buggy and the MR is solving the issue while keeping existing cases to work (existing cases are to be sure that all day events are always set in local time zone)
Currently, everything is working for two reasons:
- jolla-calendar is creating timed events with a time zone, while creating all day events without a time zone, so the toLocalZone() conversion in mkcal to detect all day feature is working.
- events coming from ICAL data are set dateOnly and provided in local time zone, so it's fine also.
So this MR is keeping the current all day detection for local time zone and correcting the issue for date time provided with time zone as demonstrated in the tests.
@pvuorela and @chriadam I understand this is a sensitive move, but while testing with upstream kcalcore, I discovered this issue with all day events and I think this is very fragile and not future proof to enforce the users of mkcal to provide all day event date times in local time only (particularly, it's written nowhere as far as I know).