summaryrefslogtreecommitdiffstats
path: root/tests
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-19 11:29:46 +0200
commit3a71e387d9759d87241c0c69b2c54f67ca547e10 (patch)
treee181c54ff5477c04420dc5356eb420a92dc27388 /tests
parent4ddc50c0cd16ddd146ea9ea21d6565c8f4a5e2bc (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> (cherry picked from commit 8286daba038d3c90d2bc06785ffcf9c0c603cb83) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index b128ccebc5..42347d6788 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -3319,6 +3319,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;
{