summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2019-09-05 17:18:56 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2019-09-13 10:47:41 +0200
commit8286daba038d3c90d2bc06785ffcf9c0c603cb83 (patch)
treea36784e5b7c3d565a7ccbb00b13b769f0e81430c /tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
parent9864d2c6f3b628ca9f07a56b197e77bd43931cca (diff)
MS TZ data: avoid calculating a date in year 0
There is no year 0 in the proleptic Gregorian calendar, so QDate() won't be happy if asked for a date in it. Tweak scanning of the data we get from MS-Win so as to avoid a date calculation that could otherwise happen in year 0 when constructing QDateTime(QDate(1, 1, 1), QTime(0, 0, 0), QTimeZone("Australia/Sydney")). Added a test for this case, which Oliver Wolff has kindly verified does reproduce the assertion failure. However, Coin is unable to reproduce, as all its MS builds are configured with -release, so Q_ASSERT() does nothing. (The relevant code then skips over year 0, albeit for the wrong reasons, and gets the right results, albeit inefficiently, leaving no other symptom by which to detect the problem.) Fixes: QTBUG-78051 Change-Id: Ife8a7470e5bd450bc421e89b3f1e1211756fc889 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp')
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index ac1b903aa1..531ac2995f 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -3352,6 +3352,14 @@ void tst_QDateTime::timeZones() const
QCOMPARE(dt3.timeSpec(), dt1.timeSpec());
QCOMPARE(dt3.timeZone(), dt1.timeZone());
+ // The start of year 1 should be *describable* in any zone (QTBUG-78051)
+ dt3 = QDateTime(QDate(1, 1, 1), QTime(0, 0, 0), ausTz);
+ QVERIFY(dt3.isValid());
+ // Likewise the end of year -1 (a.k.a. 1 BCE).
+ dt3 = dt3.addMSecs(-1);
+ QVERIFY(dt3.isValid());
+ QCOMPARE(dt3, QDateTime(QDate(-1, 12, 31), QTime(23, 59, 59, 999), ausTz));
+
// Check datastream serialises the time zone
QByteArray tmp;
{