Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.2
-
None
-
c3590c76775c889fde13dc155c2a31508db612e9
Description
The behaviour of QDateTime::setTime is different in Qt 5.3.2 compared to Qt 5.1.1 and Qt 4 in general.
In Qt 5.1.1 the QDateTime internal time was set to the provided time, no matter if it was valid or not.
In Qt 5.3. though the time is only accepted if it is valid. If the time is not valid while the date is, then the time will be set to midnight.
Therefore the behaviour is different, while the documentation remains the same:
Sets the time part of this datetime to time.
For example:
QDateTime dt; dt.setDate(QDate(2014, 12, 10)); QTime invalid_time = QTime(99, 99, 99); dt.setTime(invalid_time); QVERIFY(dt.isValid()); // false on Qt 5.1.1 and true on Qt 5.3.2 QVERIFY(dt.getTime().isValid()); // false on Qt 5.1.1 and true on Qt 5.3.2 QCOMPARE(dt.getTime(), invalid_time); // true on Qt 5.1.1 false on Qt 5.3.2
So either there is a Bug in the code or the documentation needs to be updated to reflect the new behaviour.