Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
4.7.4
-
None
Description
A date time is stored in SQLite as UTC.
However, when I retrieve the date time via a query, the resulting QDateTime object uses the UTC time as local time, resulting in an offset when compared to a local time.
QSqlQuery query("SELECT datetime('now')");
QVERIFY(query.next());
QDateTime dtdb = query.value(0).toDateTime(); // UTC time
QCOMPARE(dtdb.timeSpec(), Qt::LocalTime); // this should be UTC, or read as a UTC time
QDateTime dtqt = QDateTime::currentDateTime(); // local time
int offset = dtdb.toTime_t() - dtqt.toTime_t(); // this should be very close zero, however this value is the same as the UTC offset to the local time (in seconds)