QML locale.firstDayOfWeek returns 7 for Sunday
To match JS Date object, Sunday should be 0. Change-Id: I662c0b1fcbf921fa1c4bb58f900366dd088b343b Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
This commit is contained in:
parent
66ce518181
commit
c5f65d8597
|
@ -524,7 +524,10 @@ v8::Handle<v8::Value> QDeclarativeNumberExtension::fromLocaleString(const v8::Ar
|
|||
static v8::Handle<v8::Value> locale_get_firstDayOfWeek(v8::Local<v8::String>, const v8::AccessorInfo &info)
|
||||
{
|
||||
GET_LOCALE_DATA_RESOURCE(info.This());
|
||||
return v8::Integer::New(r->locale.firstDayOfWeek());
|
||||
int fdow = int(r->locale.firstDayOfWeek());
|
||||
if (fdow == 7)
|
||||
fdow = 0; // Qt::Sunday = 7, but Sunday is 0 in JS Date
|
||||
return v8::Integer::New(fdow);
|
||||
}
|
||||
|
||||
static v8::Handle<v8::Value> locale_get_measurementSystem(v8::Local<v8::String>, const v8::AccessorInfo &info)
|
||||
|
|
|
@ -68,6 +68,8 @@ private slots:
|
|||
void dayName();
|
||||
void standaloneDayName_data();
|
||||
void standaloneDayName();
|
||||
void firstDayOfWeek_data();
|
||||
void firstDayOfWeek();
|
||||
void weekDays_data();
|
||||
void weekDays();
|
||||
void uiLanguages_data();
|
||||
|
@ -154,7 +156,6 @@ void tst_qdeclarativelocale::addPropertyData(const QString &l)
|
|||
LOCALE_PROP(QString,negativeSign),
|
||||
LOCALE_PROP(QString,positiveSign),
|
||||
LOCALE_PROP(QString,exponential),
|
||||
LOCALE_PROP(int,firstDayOfWeek),
|
||||
LOCALE_PROP(int,measurementSystem),
|
||||
LOCALE_PROP(int,textDirection),
|
||||
{ 0, QVariant() }
|
||||
|
@ -426,6 +427,41 @@ void tst_qdeclarativelocale::standaloneDayName()
|
|||
delete obj;
|
||||
}
|
||||
|
||||
void tst_qdeclarativelocale::firstDayOfWeek_data()
|
||||
{
|
||||
QTest::addColumn<QString>("locale");
|
||||
|
||||
QTest::newRow("en_US") << "en_US";
|
||||
QTest::newRow("de_DE") << "de_DE";
|
||||
QTest::newRow("ar_SA") << "ar_SA";
|
||||
QTest::newRow("hi_IN") << "hi_IN";
|
||||
QTest::newRow("zh_CN") << "zh_CN";
|
||||
QTest::newRow("th_TH") << "th_TH";
|
||||
}
|
||||
|
||||
void tst_qdeclarativelocale::firstDayOfWeek()
|
||||
{
|
||||
QFETCH(QString, locale);
|
||||
|
||||
QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
|
||||
|
||||
QObject *obj = c.create();
|
||||
QVERIFY(obj);
|
||||
|
||||
QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
|
||||
Q_ARG(QVariant, QVariant(locale)));
|
||||
|
||||
QVariant val = obj->property("firstDayOfWeek");
|
||||
QVERIFY(val.type() == QVariant::Int);
|
||||
|
||||
int day = int(QLocale(locale).firstDayOfWeek());
|
||||
if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
|
||||
day = 0;
|
||||
QCOMPARE(day, val.toInt());
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
void tst_qdeclarativelocale::weekDays_data()
|
||||
{
|
||||
QTest::addColumn<QString>("locale");
|
||||
|
|
Loading…
Reference in New Issue