diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2023-01-16 16:58:27 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2023-01-19 17:57:04 +0100 |
commit | 2d7b9b02e991aecb51a27467f577b07563fd0e15 (patch) | |
tree | 71c766f66121385712cc27a96e9ceb35d4e90661 /src/corelib/time/qdatetime.cpp | |
parent | 5c40cb0f1a8fad03edb3ef0f97df15e9dd643bdf (diff) |
QRoundingDown: make the numerator a template parameter
It's always a constexpr (or static const that could be constexpr; fix
the cases of this while I'm here) or an integer literal, so we can, so
we might as well.
Change-Id: I61e9bcdb27f4a05f011ccce16b5f15d0dade0782
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/time/qdatetime.cpp')
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index f6e7c511cb..098b47e31a 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2139,7 +2139,7 @@ QTime QTime::addMSecs(int ms) const { QTime t; if (isValid()) - t.mds = QRoundingDown::qMod(ds() + ms, MSECS_PER_DAY); + t.mds = QRoundingDown::qMod<MSECS_PER_DAY>(ds() + ms); return t; } @@ -2507,7 +2507,7 @@ typedef QDateTimePrivate::QDateTimeData QDateTimeData; // Converts milliseconds since the start of 1970 into a date and/or time: static qint64 msecsToJulianDay(qint64 msecs) { - return JULIAN_DAY_FOR_EPOCH + QRoundingDown::qDiv(msecs, MSECS_PER_DAY); + return JULIAN_DAY_FOR_EPOCH + QRoundingDown::qDiv<MSECS_PER_DAY>(msecs); } static QDate msecsToDate(qint64 msecs) @@ -2517,7 +2517,7 @@ static QDate msecsToDate(qint64 msecs) static QTime msecsToTime(qint64 msecs) { - return QTime::fromMSecsSinceStartOfDay(QRoundingDown::qMod(msecs, MSECS_PER_DAY)); + return QTime::fromMSecsSinceStartOfDay(QRoundingDown::qMod<MSECS_PER_DAY>(msecs)); } // True if combining days with millis overflows; otherwise, stores result in *sumMillis @@ -3053,7 +3053,7 @@ static QPair<QDate, QTime> getDateTime(const QDateTimeData &d) { auto status = getStatus(d); const qint64 msecs = getMSecs(d); - const qint64 days = QRoundingDown::qDiv(msecs, MSECS_PER_DAY); + const qint64 days = QRoundingDown::qDiv<MSECS_PER_DAY>(msecs); return { status.testFlag(QDateTimePrivate::ValidDate) ? QDate::fromJulianDay(JULIAN_DAY_FOR_EPOCH + days) : QDate(), |