Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.0
-
None
-
Ubuntu 20
-
-
21
-
3d785249ba43cf4bd895ed679bac2791e0130dc5 (qt/qtbase/dev) b8f9c649dfb503a09dc3bc5714701bd059994cf5 (qt/qtbase/6.0) 91695b584ebaec6bac44bf52a4eab44da47d5a59 (qt/tqtc-qtbase/tqtc/lts-5.15)
-
Qt6_Foundation_Sprint 23, Qt6_Foundation_Sprint 24
Description
On Ubuntu20, QDateTimeEdit unit tests fail with errors like
FAIL! : tst_QDateTimeEdit::stepIntoDSTGap(hour down into 02:00 gap) Compared values are not the same Actual (edit.dateTime()): 2007/03/25 00:00:10.000[CET] Expected (end) : 2007/03/25 01:00:10.000[CET] Loc: [../tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp(4747)]
A simpler reproducer is attached.
A patch which adds a unit test reproducing the problem in a simpler form in QDateTime (without QDateTimeEdit) is in Gerrit .
Observation:
When creating a QDateTime at e.g. 2007-03-25 02:00:00 (just at the beginning of the gap hour), we end up with a QDateTime at 2007-03-25 01:00:00 (one hour before the gap hour).
Analysis:
Creating the QDateTime at the beginning of the gap hour (I used 2007-03-25 02:00:00) creates a QDateTime with unknown DST status. It correctly calculates its local milliseconds since Epoch in winter time. Then in
QDateTimePrivate::create
is a call to
refreshZonedDateTime (qdatetime.cpp:2793).
This calls (qdatetime.cpp:2813)
epochMSecs = localMSecsToEpochMSecs(msecs, &dstStatus, &testDate, &testTime);
which correctly identifies the time to be (2007-03-25 03:00:00 DST). Here the problem arises. The DST information of the QDateTime object in question is updated from the result of localMSecsToEpochMSecs in (qdatetime.cpp:2814)
status = mergeDaylightStatus(status, dstStatus);
but the date/time information (given correctly in testDate/testTime) is not updated. So we end up with an object thinking it is 2007-03-25 02:00:00 DST, which is 2007-03-25 01:00:00. This is not what was asked for.
Attachments
Issue Links
- is duplicated by
-
QTBUG-89208 tst_QDateTimeEdit::springForward() failed on openSUSE 15.2 in CI
- Closed