always use UTC timestamp for PimItem datetime and atime
ClosedPublic

Authored by mkoller on Apr 30 2017, 5:06 PM.

Details

Summary

There were some inconsistent usages of QDateTime::currentDateTime() and QDateTime::currentDateTimeUtc()
Sometimes items in the DB ended up having local time, most of them UTC (I mainly saw local time on these which had the empty-RID problem).
This patch now uses always UTC

Diff Detail

Repository
R165 Akonadi
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mkoller created this revision.Apr 30 2017, 5:06 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptApr 30 2017, 5:06 PM
Restricted Application added a subscriber: KDE PIM. · View Herald Transcript
dvratil edited edge metadata.May 3 2017, 9:01 AM

Thanks!

There is one more place that you could fix just for the sake of semantics: in akonadidb.xml we use QDateTime::currentDateTime() to represent the default value of some columns, you could change that to currentDateTimeUtc() too, and then adjust the code in DbInitializer::sqlValue() accordingly. The "QDateTime::currentDateTime()" here is not executed anywhere, it's only used as a string to represent what the default value is going to be.

An interesting thing to look into could be writing a test to make sure that we correctly process the datetime returned from each database to be in UTC. In the past, there were issues that SQL returned the datetime in UTC, while MySQL in local time without timezone, not sure what PSQL did. I tried to normalize all of these (see Utils::variantToDateTime()) beut it's only used for the generated Entities, not in regular SQL queries. But that's completely out-of-scope fo this change and will probably require a bit of work.

src/private/protocol.cpp
797 ↗(On Diff #14035)

This seems to have sneaked its way into multiple of your reviews :-) Commit it separately, please.

mkoller updated this revision to Diff 14140.May 4 2017, 5:52 PM

changed the mentioned 2 other places for generated code

dvratil accepted this revision.May 5 2017, 7:19 AM
This revision is now accepted and ready to land.May 5 2017, 7:19 AM
This revision was automatically updated to reflect the committed changes.