QDateTime: remove a few hardcoded values in favor of <chrono> constants

Change-Id: I6d3880c7d99d4fc494c8fffd16fb01b9d9480c67
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Thiago Macieira 2022-06-22 10:33:05 -07:00
parent 5e67e7efaa
commit 159a52bf3e

View File

@ -26,6 +26,8 @@
#include "qtimezone.h"
#endif
#include <chrono>
QT_BEGIN_NAMESPACE
class QDateTimePrivate : public QSharedData
@ -113,13 +115,14 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimePrivate::StatusFlags)
namespace QtPrivate {
namespace DateTimeConstants {
constexpr qint64 MINS_PER_HOUR = 60;
using namespace std::chrono;
constexpr qint64 SECS_PER_MIN = minutes::period::num;
constexpr qint64 SECS_PER_HOUR = hours::period::num;
constexpr qint64 SECS_PER_DAY = SECS_PER_HOUR * 24; // std::chrono::days is C++20
constexpr qint64 SECS_PER_MIN = 60;
constexpr qint64 SECS_PER_HOUR = SECS_PER_MIN * MINS_PER_HOUR;
constexpr qint64 SECS_PER_DAY = SECS_PER_HOUR * 24;
constexpr qint64 MINS_PER_HOUR = std::ratio_divide<hours::period, minutes::period>::num;
constexpr qint64 MSECS_PER_SEC = 1000;
constexpr qint64 MSECS_PER_SEC = milliseconds::period::den;
constexpr qint64 MSECS_PER_MIN = SECS_PER_MIN * MSECS_PER_SEC;
constexpr qint64 MSECS_PER_HOUR = SECS_PER_HOUR * MSECS_PER_SEC;
constexpr qint64 MSECS_PER_DAY = SECS_PER_DAY * MSECS_PER_SEC;