summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2020-11-27 15:42:36 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-17 19:38:08 +0000
commitb8f9c649dfb503a09dc3bc5714701bd059994cf5 (patch)
treeabf017abbea56cb8e0b63c522059c2c7e11c8fe9 /src/corelib
parent69f7b6be724296f1a67eca90b3a8bd3924972065 (diff)
Restore previous QDateTime behavior in DST gap
Historic QDateTime behavior when being asked to create a QDateTime in the DST gap was to interpret the given date as if it was in the time before that gap, mapping it to a point in time after the gap. This has changed with a04411119ead3d4473e4f0ac4bceedc585977b2f . Since then, the given date is interpreted as if it was in the time after the gap, thus being mapped to a point in time before the gap. This patch restores the historic behavior. This was not caught by Coin because machines ran in timezone "Atlantic/Reykjavik" which does not have DST since 1967. This patch changes tests to always run in "Europe/Oslo". Driveby: Test function "findSpring" did some operations in local time, even though being asked to work in a specific time zone. Fixed that. Fixes: QTBUG-86960 Fixes: QTBUG-89208 Change-Id: Iecce5898bf9711a10e7dfc0a25e4bbeaed1c8ade Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 3d785249ba43cf4bd895ed679bac2791e0130dc5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/time/qdatetime.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 757636ede2..5ed72dd5e3 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -2856,21 +2856,21 @@ static void refreshZonedDateTime(QDateTimeData &d, Qt::TimeSpec spec)
qint64 epochMSecs = 0;
QDate testDate;
QTime testTime;
+ auto dstStatus = extractDaylightStatus(status);
if (spec == Qt::LocalTime) {
- auto dstStatus = extractDaylightStatus(status);
epochMSecs = localMSecsToEpochMSecs(msecs, &dstStatus, &testDate, &testTime);
- status = mergeDaylightStatus(status, dstStatus);
#if QT_CONFIG(timezone)
// else spec == Qt::TimeZone, so check zone is valid:
} else if (d->m_timeZone.isValid()) {
epochMSecs = QDateTimePrivate::zoneMSecsToEpochMSecs(
- msecs, d->m_timeZone, extractDaylightStatus(status), &testDate, &testTime);
+ msecs, d->m_timeZone, dstStatus, &testDate, &testTime);
#endif // timezone
} // else: testDate, testTime haven't been set, so are invalid.
// Cache the offset to use in offsetFromUtc() &c.
offsetFromUtc = (msecs - epochMSecs) / 1000;
if (testDate.isValid() && testTime.isValid()
&& timeToMSecs(testDate, testTime) == msecs) {
+ status = mergeDaylightStatus(status, dstStatus);
status |= QDateTimePrivate::ValidDateTime;
} else {
status &= ~QDateTimePrivate::ValidDateTime;