From fb15a8c24209cee59f2d7c5f0d00f327a68014d6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 4 Nov 2016 14:55:07 +0100 Subject: tst_qqmllocale: shuffle commentary on JS Date's month numbering While it departs from common date numbering, as used by QDateTime, the 0=Jan numbering used by JS's Date was copied from Java's Date, which (probably) copied it from ANSI C's struct tm; and C likes to count from zero. So don't call it weird; and let's comment on it where it's actually relevant (in JS code with the offset, rather than against uses of QDate, which uses 1=Jan numbering) and only once. Change-Id: I926138e88583339bec8641e3b28a642794dc217d Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllocale/data/date.qml | 1 + tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'tests/auto/qml/qqmllocale') diff --git a/tests/auto/qml/qqmllocale/data/date.qml b/tests/auto/qml/qqmllocale/data/date.qml index 3f58497d22..d8cd043cdf 100644 --- a/tests/auto/qml/qqmllocale/data/date.qml +++ b/tests/auto/qml/qqmllocale/data/date.qml @@ -7,6 +7,7 @@ QtObject { locale = Qt.locale(l) } + // Month number 9 is October: JS Date()'s month range is 0 to 11. function toLocaleString(fmt) { var d = new Date(2011, 9, 7, 18, 53, 48, 345); if (fmt < 0) diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 7a6cb7c929..e0836468fb 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -641,7 +641,7 @@ void tst_qqmllocale::dateToLocaleString() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -702,7 +702,7 @@ void tst_qqmllocale::dateToLocaleStringFormatted() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -733,7 +733,7 @@ void tst_qqmllocale::dateToLocaleDateString() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -794,7 +794,7 @@ void tst_qqmllocale::dateToLocaleDateStringFormatted() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -825,7 +825,7 @@ void tst_qqmllocale::dateToLocaleTimeString() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -886,7 +886,7 @@ void tst_qqmllocale::dateToLocaleTimeStringFormatted() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, -- cgit v1.2.3