Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.9.0 Beta 2
-
None
-
0679b96338b0803a3c9aced772396470bcf7e1e6
Description
Actually qtbase/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp has this code
bool QSQLiteATResult::exec() { ... case QVariant::DateTime: { const QDateTime dateTime = value.toDateTime(); const QString str = dateTime.toString(QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz")); res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(), str.size() * sizeof(ushort), SQLITE_TRANSIENT); break; }
But SQLite supports ISO 8601 https://sqlite.org/lang_datefunc.html, thus it would be more judicious to use
dateTime.toString(Qt::ISODate)
so as to keep the timezone. This code has an issue since QVariant::toDateTime() set the timezone to local time when we read back the date time. An UTC date time is thus incorrectly restored as a local time.
See also QTBUG-26842