summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-02-18 17:24:18 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2021-04-16 10:22:27 +0200
commitb4a875544ba8f2d11e183d67f45891d6149203ed (patch)
tree0aa1ad44a4594e36bbb32b55ced0e8201d49a3dd /tests
parent455994c2eef28ca4ed6d52103af47364e4145555 (diff)
Extend time_t-based handling all the way to the end of time_t
At least some modern 64-bit systems have widened time_t to 64 bits fixing the "Unix time" problem. (This is even the default on MS-Win, although the system functions artificially limit the accepted range to 1970 through 3000.) Even the 32-bit range extends into January 2038 but the code was artificially cutting this off at the end of 2037. This is a preparation for using the same also all the way back to the start of time_t. In the process, simplify and tidy up the logic of the existing code, update the docs (this includes correcting some misinformation) and revise some tests. Fixes: QTBUG-73225 Change-Id: Ib8001b5a982386c747eda3dea2b5a26eedd499ad Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index c2f4e82896..166ce260a5 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -615,7 +615,7 @@ void tst_QDateTime::setMSecsSinceEpoch_data()
<< Q_INT64_C(-123456789)
<< QDateTime(QDate(1969, 12, 30), QTime(13, 42, 23, 211), Qt::UTC)
<< QDateTime(QDate(1969, 12, 30), QTime(14, 42, 23, 211), Qt::LocalTime);
- QTest::newRow("non-time_t")
+ QTest::newRow("post-32-bit-time_t")
<< (Q_INT64_C(1000) << 32)
<< QDateTime(QDate(2106, 2, 7), QTime(6, 28, 16), Qt::UTC)
<< QDateTime(QDate(2106, 2, 7), QTime(7, 28, 16));
@@ -713,10 +713,7 @@ void tst_QDateTime::setMSecsSinceEpoch()
}
QCOMPARE(dt.toMSecsSinceEpoch(), msecs);
-
- if (quint64(msecs / 1000) < 0xFFFFFFFF) {
- QCOMPARE(qint64(dt.toSecsSinceEpoch()), msecs / 1000);
- }
+ QCOMPARE(qint64(dt.toSecsSinceEpoch()), msecs / 1000);
QDateTime reference(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC);
QCOMPARE(dt, reference.addMSecs(msecs));
@@ -766,11 +763,10 @@ void tst_QDateTime::fromMSecsSinceEpoch()
QCOMPARE(dtUtc.toMSecsSinceEpoch(), msecs);
QCOMPARE(dtOffset.toMSecsSinceEpoch(), msecs);
- if (quint64(msecs / 1000) < 0xFFFFFFFF) {
+ if (!localOverflow)
QCOMPARE(qint64(dtLocal.toSecsSinceEpoch()), msecs / 1000);
- QCOMPARE(qint64(dtUtc.toSecsSinceEpoch()), msecs / 1000);
- QCOMPARE(qint64(dtOffset.toSecsSinceEpoch()), msecs / 1000);
- }
+ QCOMPARE(qint64(dtUtc.toSecsSinceEpoch()), msecs / 1000);
+ QCOMPARE(qint64(dtOffset.toSecsSinceEpoch()), msecs / 1000);
QDateTime reference(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC);
if (!localOverflow)