aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-07-30 15:37:09 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2020-09-01 16:57:08 +0200
commit5234bed6a242d827799571db4fe7fd94b54df4db (patch)
treeb03d83a620c2b9e33e2c467b95f204251af0a824 /src/qml/jsruntime/qv4engine.cpp
parent572882fd67d8d4ca138f6ae75150ed6188aaa7c6 (diff)
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp2
1 files changed, 1 insertions, 1 deletions
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<const QDateTime *>(ptr)));
case QMetaType::QDate:
- return QV4::Encode(newDateObject(QDateTime(*reinterpret_cast<const QDate *>(ptr), QTime(0, 0, 0), Qt::UTC)));
+ return QV4::Encode(newDateObject(reinterpret_cast<const QDate *>(ptr)->startOfDay(Qt::UTC)));
case QMetaType::QTime:
return QV4::Encode(newDateObjectFromTime(*reinterpret_cast<const QTime *>(ptr)));
#if QT_CONFIG(regularexpression)