diff options
Diffstat (limited to 'src/corelib/time/qdatetime.cpp')
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 2f1f80d70d..c3e9b49b25 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -130,7 +130,7 @@ ParsedInt readInt(QStringView text) struct ParsedRfcDateTime { QDate date; QTime time; - int utcOffset; + int utcOffset = 0; }; static int shortDayFromName(QStringView name) @@ -3256,7 +3256,7 @@ static void checkValidDateTime(QDateTimeData &d, QDateTime::TransitionResolution } } -static void reviseTimeZone(QDateTimeData &d, QTimeZone zone, +static void reviseTimeZone(QDateTimeData &d, const QTimeZone &zone, QDateTime::TransitionResolution resolve) { Qt::TimeSpec spec = zone.timeSpec(); @@ -5350,10 +5350,19 @@ QDateTime QDateTime::currentDateTimeUtc() \since 6.4 Constructs a datetime representing the same point in time as \a time, - using Qt::UTC as its specification. + using Qt::UTC as its time representation. - The clock of \a time must be compatible with \c{std::chrono::system_clock}, - and the duration type must be convertible to \c{std::chrono::milliseconds}. + The clock of \a time must be compatible with + \c{std::chrono::system_clock}; in particular, a conversion + supported by \c{std::chrono::clock_cast} must exist. After the + conversion, the duration type of the result must be convertible to + \c{std::chrono::milliseconds}. + + If this is not the case, the caller must perform the necessary + clock conversion towards \c{std::chrono::system_clock} and the + necessary conversion of the duration type + (cast/round/floor/ceil/...) so that the input to this function + satisfies the constraints above. \note This function requires C++20. @@ -5361,6 +5370,22 @@ QDateTime QDateTime::currentDateTimeUtc() */ /*! + \since 6.4 + \overload + + Constructs a datetime representing the same point in time as \a time, + using Qt::UTC as its time representation. +*/ +QDateTime QDateTime::fromStdTimePoint( + std::chrono::time_point< + std::chrono::system_clock, + std::chrono::milliseconds + > time) +{ + return fromMSecsSinceEpoch(time.time_since_epoch().count(), QTimeZone::UTC); +} + +/*! \fn QDateTime QDateTime::fromStdTimePoint(const std::chrono::local_time<std::chrono::milliseconds> &time) \since 6.4 |