Skip to content

Fix handling of UTC vs. local time for database engines

Daniel Vrátil requested to merge work/dvratil/bko483061-db-datetime into master

Each database handles datetimes slightly differently. Our biggest problem was MySQL, where the QMYSQL driver strips timezone, so the MySQL server assumes the time is a local time. Akonadi was, however, passing a UTC time, which then MySQL tried to interpret as local time, which lead to two issues:

  1. it failed if the time was not a valid time in local timezone (DST)
  2. it required special handling when reading the time back from DB because MySQL returned UTC time but with local timezone set.

So instead we make sure we handle datetime properly when insert it into the database. This can be handled from a singular place in QueryBuilder, so it's fully transparent to the caller.

There's no migration for the existing database, since at worst the time is slightly off and shouldn't have actual impact on functionality.

This has also been fixed independently in Qt, so in the future we might be able to drop this completely.

BUG: 483060

Edited by Daniel Vrátil

Merge request reports