From b8f9c649dfb503a09dc3bc5714701bd059994cf5 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Fri, 27 Nov 2020 15:42:36 +0100 Subject: 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 (cherry picked from commit 3d785249ba43cf4bd895ed679bac2791e0130dc5) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index b7ae7df5ed..05124d1ad6 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -4622,7 +4622,7 @@ static QDateTime findSpring(int year, const QTimeZone &timeZone) return QDateTime(); // Southern hemisphere spring is after midsummer - const QDateTime midSummer = QDate(year, 6, 21).startOfDay(); + const QDateTime midSummer = QDate(year, 6, 21).startOfDay(timeZone); const QTimeZone::OffsetData transition = midSummer.isDaylightTime() ? timeZone.previousTransition(midSummer) : timeZone.nextTransition(midSummer); @@ -4744,7 +4744,7 @@ void tst_QDateTimeEdit::stepIntoDSTGap_data() QTest::addColumn("steps"); QTest::addColumn("end"); - const QTimeZone timeZone = QTimeZone::systemTimeZone(); + const QTimeZone timeZone = QTimeZone("Europe/Oslo"); if (!timeZone.hasDaylightTime()) QSKIP("This test needs to run in a timezone that observes DST!"); -- cgit v1.2.3