diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-08-24 13:48:18 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-08-25 20:36:37 +0200 |
| commit | 555125416eb1a12e15dddb57207ce7d87751a64b (patch) | |
| tree | f51faf78fcc045c83af7599ccd382bea96e3d10a /src/qml/jsruntime/qv4dateobject.cpp | |
| parent | ede3389a3e152d7436bda6a53dd93e8847ab026e (diff) | |
QmlCompiler: Allow coercing date values to numbers
This is the equivalent of JavaScript's valueOf().
Change-Id: If850519d6dbc7354b447acb6aad8ac04211d059d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4dateobject.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4dateobject.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index e6742c6f40..d168517901 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -719,6 +719,13 @@ QString DateObject::dateTimeToString(const QDateTime &dateTime, ExecutionEngine return ToString(TimeClip(dateTime.toMSecsSinceEpoch()), engine->localTZA); } +double DateObject::dateTimeToNumber(const QDateTime &dateTime) +{ + if (!dateTime.isValid()) + return qQNaN(); + return TimeClip(dateTime.toMSecsSinceEpoch()); +} + QDateTime DateObject::stringToDateTime(const QString &string, ExecutionEngine *engine) { return ToDateTime(ParseString(string, engine->localTZA), QTimeZone::LocalTime); |
