From 5234bed6a242d827799571db4fe7fd94b54df4db Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 30 Jul 2020 15:37:09 +0200 Subject: Use QDate::startOfDay() rather than assuming midnight exists When converting a QDate to a QDateTime, startOfDay() takes care of avoiding any gaps in time at the start of the day, where naively asking for QTime(0, 0, 0) can produce an invalid date-time. Change-Id: I24f3d230eb1ee7396600b030ad1305e060215cbd Reviewed-by: Fabian Kosmale --- src/qml/jsruntime/qv4engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/jsruntime') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 7a858ed503..e4d3d79541 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1674,7 +1674,7 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant) case QMetaType::QDateTime: return QV4::Encode(newDateObject(*reinterpret_cast(ptr))); case QMetaType::QDate: - return QV4::Encode(newDateObject(QDateTime(*reinterpret_cast(ptr), QTime(0, 0, 0), Qt::UTC))); + return QV4::Encode(newDateObject(reinterpret_cast(ptr)->startOfDay(Qt::UTC))); case QMetaType::QTime: return QV4::Encode(newDateObjectFromTime(*reinterpret_cast(ptr))); #if QT_CONFIG(regularexpression) -- cgit v1.2.3