diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-11-04 14:55:07 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-01-10 18:11:26 +0000 |
commit | fb15a8c24209cee59f2d7c5f0d00f327a68014d6 (patch) | |
tree | 780bff6a4663a63911a5e7712ee8f98e2b6a69cb /tests | |
parent | e7bfab82b45df088d15cbb4c5213ca94e260220d (diff) |
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 <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmllocale/data/date.qml | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 12 |
2 files changed, 7 insertions, 6 deletions
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, |