diff --git a/src/corelib/time/qdatetime_p.h b/src/corelib/time/qdatetime_p.h index 5ac65bc1a5..de4de85d8c 100644 --- a/src/corelib/time/qdatetime_p.h +++ b/src/corelib/time/qdatetime_p.h @@ -26,6 +26,8 @@ #include "qtimezone.h" #endif +#include + 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::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;