diff options
-rw-r--r-- | src/qml/jsruntime/qv4dateobject.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/date.qml | 6 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index e00a705700..b3c340ccb2 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -480,6 +480,8 @@ static inline double ParseString(const QString &s) QDateTime dt = QDateTime::fromString(s, Qt::TextDate); if (!dt.isValid()) dt = QDateTime::fromString(s, Qt::ISODate); + if (!dt.isValid()) + dt = QDateTime::fromString(s, Qt::RFC2822Date); if (!dt.isValid()) { QStringList formats; formats << QStringLiteral("M/d/yyyy") diff --git a/tests/auto/qml/qqmlecmascript/data/date.qml b/tests/auto/qml/qqmlecmascript/data/date.qml index 0dcba71ae3..41dcaafa33 100644 --- a/tests/auto/qml/qqmlecmascript/data/date.qml +++ b/tests/auto/qml/qqmlecmascript/data/date.qml @@ -17,4 +17,10 @@ Item { var dt = new Date(""); return isNaN(dt); } + + function test_rfc2822_date() + { + var dt = new Date("Wed, 18 Sep 2013 07:00:51 -0700"); + return dt.getTime(); + } } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 019d6790e1..38a2affe3a 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -7361,7 +7361,8 @@ void tst_qqmlecmascript::dateParse() QMetaObject::invokeMethod(object, "test_is_invalid_qtDateTime", Q_RETURN_ARG(QVariant, q)); QVERIFY(q.toBool() == true); - + QMetaObject::invokeMethod(object, "test_rfc2822_date", Q_RETURN_ARG(QVariant, q)); + QCOMPARE(q.toLongLong(), 1379512851000LL); } void tst_qqmlecmascript::utcDate() |