diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-06-04 15:32:32 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-05 04:35:50 +0200 |
commit | 2d1fc405b4048560a6f80add6ee6492fa934c91f (patch) | |
tree | 61088efa7a2e75092562e169f2ac14df7be599bd /src/qml/qml | |
parent | 805c30e809a86cc1feabeb3bdbee943a7bbf8796 (diff) |
Allow the global JS UTC offset to be invalidated
If the system timezone is changed, it is necessary to inform
V8 so that the global offset-from-UTC value can be recalculated.
This changes adds the 'timeZoneUpdated' function to the JS
'Date' class exported by QML, which allows QML applications to
inform V8 when the timezone has been updated.
Change-Id: Ic5898ca7bc640002a4a6fd5a52b8623d87ee8085
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmllocale.cpp | 18 | ||||
-rw-r--r-- | src/qml/qml/qqmllocale_p.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 7d2dafe3b3..9a2ec6f0e3 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -131,6 +131,13 @@ static const char *dateFromLocaleDateStringFunction = " })" "})"; +static const char *dateTimeZoneUpdatedFunction = + "(function(timeZoneUpdatedFunc) { " + " Date.timeZoneUpdated = (function() {" + " return timeZoneUpdatedFunc.apply(null, arguments);" + " })" + "})"; + static void registerFunction(QV8Engine *engine, const char *script, v8::InvocationCallback func) { @@ -150,6 +157,7 @@ void QQmlDateExtension::registerExtension(QV8Engine *engine) registerFunction(engine, dateFromLocaleStringFunction, fromLocaleString); registerFunction(engine, dateFromLocaleTimeStringFunction, fromLocaleTimeString); registerFunction(engine, dateFromLocaleDateStringFunction, fromLocaleDateString); + registerFunction(engine, dateTimeZoneUpdatedFunction, timeZoneUpdated); } v8::Handle<v8::Value> QQmlDateExtension::toLocaleString(const v8::Arguments& args) @@ -387,6 +395,16 @@ v8::Handle<v8::Value> QQmlDateExtension::fromLocaleDateString(const v8::Argument return QJSConverter::toDateTime(QDateTime(dt)); } +v8::Handle<v8::Value> QQmlDateExtension::timeZoneUpdated(const v8::Arguments& args) +{ + if (args.Length() != 0) + V8THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments"); + + v8::Date::DateTimeConfigurationChangeNotification(); + + return v8::Undefined(); +} + //----------------- // Number extension diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index c701c1ca1c..7007770245 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -66,6 +66,7 @@ private: static v8::Handle<v8::Value> fromLocaleString(const v8::Arguments& args); static v8::Handle<v8::Value> fromLocaleTimeString(const v8::Arguments& args); static v8::Handle<v8::Value> fromLocaleDateString(const v8::Arguments& args); + static v8::Handle<v8::Value> timeZoneUpdated(const v8::Arguments& args); }; |