Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.8.2
-
None
-
219e9fe7a (dev), 3b175fbec (6.9), 1b11ab412 (6.8)
Description
When writing a QDateTime in a DATETIME sql field (in a MySQL datatbase) QMYSQLDriver::formatValue returns a string like that
r = u'\'' + dt.date().toString(Qt::ISODate) + u'T' + dt.time().toString(Qt::ISODate) + u'\'';
and QMYSQLResult::data reads it like that
return QDateTime(date, time, QTimeZone::UTC);
Assuming it is always stored in UTC.
However, if a localTime is passed to the formatValue method (for instance QDateTime(2025-03-25 11:14:25.000 CET Qt::LocalTime)) it is stored in this format "2025-03-25T11:14:25". But when it is retrived with a SELECT, it is returned as QDateTime(2025-03-25 11:14:25.000 UTC Qt::UTC)
Edit: I know that in the docs https://doc.qt.io/qt-6/sql-driver.html#timestamp-support it says it is normal, but since MySQL does not store any timezone information, the retrieved data should not be assumed to be UTC