summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qdatetimeedit
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-06-01 18:27:48 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-06-23 14:04:08 +0200
commitc00ee2f31013e99c79b820a0db57003c110a5510 (patch)
treeca5469dd8254a8729ccb1a33eaaedeba21104417 /tests/auto/widgets/widgets/qdatetimeedit
parent5ad13ec57dc4829813557069806b44000dd836e2 (diff)
Use UTC when parsing only a date or only a time, not a date-time
This should reduce the amount of fall-out from DST complications. Also document the assumptions of QDateTimeParser's two fromString() methods (and fix the punctuation on the QDateTime parameter). Adjusted some tests to match. Since only QDateTime-returning methods will show the difference, and it's at least somewhat odd to be using those on QDateEdit or QTimeEdit, this should have little impact on API users. [ChangeLog][QtCore][Behavior Change] QDateEdit and QTimeEdit now operate in UTC, to avoid spurious complications arising from time-zone transitions (e.g. DST) causing the implicit other half to combine with the part being edited to make an invalid result. Returns from their dateTime() and other methods returning QDateTime (max/min) shall thus be in UTC where previously they were in local time. QDateTimeEdit continues using local time. The default can be over-ridden by setTimeSpec(), as ever. Change-Id: I44fece004c12342fe536bbe3048217d236fd97b2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/widgets/widgets/qdatetimeedit')
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index ad16fcc79f..9211800eb3 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -1358,7 +1358,7 @@ void tst_QDateTimeEdit::editingRanged_data()
<< QDate(2010, 12, 30) << QTime()
<< QDate(2011, 1, 2) << QTime()
<< QString::fromLatin1("01012011")
- << QDateTime(QDate(2011, 1, 1), QTime());
+ << QDateTime(QDate(2011, 1, 1), QTime(), Qt::UTC);
}
void tst_QDateTimeEdit::editingRanged()
@@ -3141,9 +3141,9 @@ void tst_QDateTimeEdit::hour12Test()
void tst_QDateTimeEdit::yyTest()
{
testWidget->setDisplayFormat("dd-MMM-yy");
- testWidget->setTime(QTime(0, 0, 0));
testWidget->setDateRange(QDate(2005, 1, 1), QDate(2010, 12, 31));
testWidget->setDate(testWidget->minimumDate());
+ testWidget->setTime(QTime(12, 0, 0)); // Mid-day to avoid DST artefacts.
testWidget->setCurrentSection(QDateTimeEdit::YearSection);
QString jan = QLocale::system().monthName(1, QLocale::ShortFormat);