It's been about 3-6 years and there's a calendar bug that has remained unsolved. Many posts about this have gone stale due to lack of details.
This issue is most notable when a list of events say, for example, on days of 1, 2, 3; the list gets populated as 1, 3, 2. This is a very hard to debug issue and to recreate in the wild it requires:
- Google Calendar (possibly present in others)
- An imported calendar into Google Calendar (this issue may or may not show up with all imported calendars)
- An event created in Google Calendar and another event from the imported calendar. Both events have to be close to each other (about day or less apart, <=24h)
This is not a mismatched timezone issue. So make sure to read (in its entirety) the detailed reddit post I made about year ago here: link to post.
With root and network sync disabled, I think it is possible to manipulate the calendar.db file to manually recreate a scenario where this bug would show without having to depend on imported calendars with the issue.
In summary (TL:DR), Kustom sorts events by unix epoch timestamps but reads event details from other columns in the calendar database file. In weird edge cases this data doesn't line up correctly with the unix timestamp.
To fix this Kustom's calendar sort logic needs to either:
- (easier in my opinion) switch away from using unix timestamps to using the startDay + startMinute columns.
- (more complex) keep sorting using unix timestamps but compare against startDay + startMinute columns and handle the edge cases separately where there things mismatch.
- (easy but leads to another bug) keep sorting using unix timestamps and parse event data from the unix timestamps as well. This would fix the misordered events bug, though the url/ical imported events would appear to start at later day or time than what is actually scheduled.
Most (if not all) of the stale posts in this forum regarding calendar events issues are due to this bug. Many of the posters didn't know how to investigate the issue. So the posts went stale due to lack of details. Hopefully this is enough info to squash this nasty bug.