summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-01-25 13:07:46 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-01-30 15:17:55 +0100
commit9135531c33551e03ef2b7287830228def0a81f5a (patch)
tree67b5c3369449cd99eb96fe56eb4d3d6b53b11fa1 /src
parent58e8ae5605abefd0f579586a890dc13fb381b2a3 (diff)
Refine QTZP_win's msecsToDate() by trusting arithmetic
Division and modulo are guaranteed to be consistent, with the former truncating towards zero, so the latter giving a remainder that either is zero or has the same sign as the numerator. In particular, when the numerator is positive, the remainder is necessarily greater than minus it, so the formerly correct but unilluminating arithmetic necessarily gave the answer one and we can just --jd rather than doing anything cleverer. Assert the fact that ensures this. Pick-to: 6.3 6.2 Change-Id: Ia718bb947192f1fd2eb36549be12d30e4ee03d58 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/time/qtimezoneprivate_win.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp
index ff8cd5548e..651fcade5e 100644
--- a/src/corelib/time/qtimezoneprivate_win.cpp
+++ b/src/corelib/time/qtimezoneprivate_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2021 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Copyright (C) 2013 John Layt <jlayt@kde.org>
** Contact: https://www.qt.io/licensing/
**
@@ -97,8 +97,8 @@ QDate msecsToDate(qint64 msecs)
}
if (msecs < 0) {
- qint64 ds = MSECS_PER_DAY - msecs - 1;
- jd -= ds / MSECS_PER_DAY;
+ Q_ASSERT(msecs > -MSECS_PER_DAY);
+ --jd;
}
return QDate::fromJulianDay(jd);