From 0f23346d2a660404d40d02a2d101eb4fc21c8b02 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 27 Jul 2023 15:10:31 +0200 Subject: QmlCompiler: Allow construction of Date objects We map Date to QDateTime and special-case its constructors. Task-number: QTBUG-111624 Change-Id: I0496f853613da3ccee9b6f6c4cf0adffa064f9f8 Reviewed-by: Fabian Kosmale Reviewed-by: Qt CI Bot --- src/qml/qml/qqml.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src/qml/qml/qqml.cpp') diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index 1e051fd37a..e7de0c85ca 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -6,21 +6,22 @@ #include #include +#include +#include #include +#include +#include #include #include #include #include -#include #include #include +#include +#include +#include #include #include -#include -#include -#include -#include -#include #include @@ -1500,7 +1501,25 @@ QVariant AOTCompiledContext::constructValueType( int ctorIndex, void *ctorArg) const { return QQmlValueTypeProvider::constructValueType( - resultMetaType, resultMetaObject, ctorIndex, ctorArg); + resultMetaType, resultMetaObject, ctorIndex, ctorArg); +} + +QDateTime AOTCompiledContext::constructDateTime(double timestamp) const +{ + return QV4::DateObject::timestampToDateTime(timestamp); +} + +QDateTime AOTCompiledContext::constructDateTime(const QString &string) const +{ + return QV4::DateObject::stringToDateTime(string, engine->handle()); +} + +QDateTime AOTCompiledContext::constructDateTime( + double year, double month, double day, double hours, + double minutes, double seconds, double msecs) const +{ + return constructDateTime(QV4::DateObject::componentsToTimestamp( + year, month, day, hours, minutes, seconds, msecs, engine->handle())); } bool AOTCompiledContext::callQmlContextPropertyLookup( -- cgit v1.2.3