diff options
Diffstat (limited to 'src/qml/qml/qqmllocale.cpp')
-rw-r--r-- | src/qml/qml/qqmllocale.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index dca13ac8d4..7af6af276a 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -314,7 +314,7 @@ ReturnedValue QQmlDateExtension::method_fromLocaleDateString(const QV4::Function QLocale locale; QString dateString = s->toQString(); QDate date = locale.toDate(dateString); - RETURN_RESULT(engine->newDateObject(QDateTime(date))); + RETURN_RESULT(engine->newDateObject(date.startOfDay())); } } @@ -341,7 +341,7 @@ ReturnedValue QQmlDateExtension::method_fromLocaleDateString(const QV4::Function dt = r->d()->locale->toDate(dateString, enumFormat); } - RETURN_RESULT(engine->newDateObject(QDateTime(dt))); + RETURN_RESULT(engine->newDateObject(dt.startOfDay())); } ReturnedValue QQmlDateExtension::method_timeZoneUpdated(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *, int argc) @@ -478,6 +478,23 @@ ReturnedValue QQmlLocaleData::method_get_firstDayOfWeek(const QV4::FunctionObjec RETURN_RESULT(fdow); } +ReturnedValue QQmlLocaleData::method_get_numberOptions(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { + QV4::Scope scope(b); + const QLocale *locale = getThisLocale(scope, thisObject); + if (!locale) + return Encode::undefined(); + int numberOptions = int(locale->numberOptions()); + RETURN_RESULT(numberOptions); +} + +ReturnedValue QQmlLocaleData::method_set_numberOptions(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { + QV4::Scope scope(b); + QLocale *locale = getThisLocale(scope, thisObject); + int const numberOptions = argc ? int(argv[0].toNumber()) : QLocale::DefaultNumberOptions; + locale->setNumberOptions(QLocale::NumberOptions {numberOptions}); + return Encode::undefined(); +} + ReturnedValue QQmlLocaleData::method_get_measurementSystem(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); @@ -701,6 +718,7 @@ QV4LocaleDataDeletable::QV4LocaleDataDeletable(QV4::ExecutionEngine *engine) o->defineAccessorProperty(QStringLiteral("amText"), QQmlLocaleData::method_get_amText, nullptr); o->defineAccessorProperty(QStringLiteral("measurementSystem"), QQmlLocaleData::method_get_measurementSystem, nullptr); o->defineAccessorProperty(QStringLiteral("exponential"), QQmlLocaleData::method_get_exponential, nullptr); + o->defineAccessorProperty(QStringLiteral("numberOptions"), QQmlLocaleData::method_get_numberOptions, QQmlLocaleData::method_set_numberOptions); prototype.set(engine, o); } @@ -873,6 +891,16 @@ ReturnedValue QQmlLocale::method_localeCompare(const QV4::FunctionObject *b, con */ /*! + \qmlproperty enumeration QtQml::Locale::NumberOption + + Holds a set of options for number-to-string and + string-to-number conversions. + + \sa Number::toLocaleString() + \sa Number::fromLocaleString() +*/ + +/*! \qmlproperty string QtQml::Locale::percent Holds the percent character of this locale. |