aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmllocale.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-04-08 15:50:09 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-08 20:51:42 +0200
commit1674bf32c8d2b52d95dab62429bb605ca9d279cc (patch)
treec6e9f240abc1b1a22ccff5b77d5c97c441f9c0d9 /src/qml/qml/qqmllocale.cpp
parent7867f6817e2367478cfcd6574bd6edefd1c5c958 (diff)
Fix remaining QQmlLocale auto-test failures
Thanks to improvements in QDateTime's parser, we can unskip a bunch of tests. What remained was dateFromLocaleTimeString, which failed because it relied on the earlier behavior of a failed conversion from a _time_ string to a date also returning an invalid date object. This behavior is restored by leaving the QDateTime object as invalid unless the converted time is valid. In Qt <= 5.1, QDateTime::setTime would make the entire datetime object invalid if the provided time was invalid. In Qt >= 5.2 it remains potentially valid if the date at least is correct - which was the case here as it was initialized from currentDateTime. Change-Id: I32a2cd2a9631cca3b12773e4c55169baa3eeaf1a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmllocale.cpp')
-rw-r--r--src/qml/qml/qqmllocale.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index fc9e2fc42a..178280b27c 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -290,8 +290,11 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte
tm = r->locale.toTime(dateString, enumFormat);
}
- QDateTime dt = QDateTime::currentDateTime();
- dt.setTime(tm);
+ QDateTime dt;
+ if (tm.isValid()) {
+ dt = QDateTime::currentDateTime();
+ dt.setTime(tm);
+ }
return QV4::Encode(engine->newDateObject(dt));
}