From a686fe7000df64026cc6059645c198141f565e15 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 19 Apr 2018 14:50:37 +0200 Subject: Apply TimeClip() in a few places it was missing When parsing or converting from a QDateTime, we didn't always check that the resulting Date object was within range (1e8 days either side of the start of 1970). Change-Id: I1bee69f9070829f68998d576c19907a827fabc39 Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4dateobject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 474c58d3fd..43947c8e6d 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -533,7 +533,7 @@ static inline double ParseString(const QString &s, double localTZA) else if (seenT) // No zone specified, treat date-time as local time t = UTC(t, localTZA); // else: treat plain date as already in UTC - return t; + return TimeClip(t); } QDateTime dt = QDateTime::fromString(s, Qt::TextDate); @@ -603,7 +603,7 @@ static inline double ParseString(const QString &s, double localTZA) } if (!dt.isValid()) return qt_qnan(); - return dt.toMSecsSinceEpoch(); + return TimeClip(dt.toMSecsSinceEpoch()); } /*! @@ -703,7 +703,7 @@ DEFINE_OBJECT_VTABLE(DateObject); void Heap::DateObject::init(const QDateTime &date) { Object::init(); - this->date = date.isValid() ? date.toMSecsSinceEpoch() : qt_qnan(); + this->date = date.isValid() ? TimeClip(date.toMSecsSinceEpoch()) : qt_qnan(); } void Heap::DateObject::init(const QTime &time) -- cgit v1.2.3