summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2019-05-15 12:35:08 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2019-05-28 06:14:32 +0000
commit5aaade8c935caa1add92f61187c0065e34cf7e0e (patch)
treeff25bd160f5a610e200816d99b1f01d3c2d0f225 /tests/auto/corelib
parent11569f7071e5ac6b50672ad400e6ed6e70ecd76b (diff)
Fix editing of QDateTimeEdit in 12-hour locales that don't use AM/PM
The code made two incorrect assumptions: that the strings used are "AM" or "PM", or would be translated. Instead, the locale provides the correct strings, and there is no need to translate. However, in order not to break existing translations, we give those preference. And that the AM/PM string is not longer than 4 characters, while in e.g Spanish/Columbia locale the strings are "A. M." and "P. M.", ie 5 characters long. Also, the use of qMin in a function that is asked to provide the maximum section length is wrong. [ChangeLog][QWidgets][QDateTimeEdit] Use the information provided by the locale to determine the AM/PM strings, unless they are already translated. Change-Id: I6d1b05376e5ac62fc58da2cdea2e6cb732ec6747 Fixes: QTBUG-72833 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 38b72ab91f..ce7cacf966 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -2490,17 +2490,20 @@ void tst_QDateTime::fromString_LOCALE_ILDATE()
void tst_QDateTime::fromStringToStringLocale_data()
{
+ QTest::addColumn<QLocale>("locale");
QTest::addColumn<QDateTime>("dateTime");
- QTest::newRow("data0") << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00));
+ QTest::newRow("frFR") << QLocale(QLocale::French, QLocale::France) << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00));
+ QTest::newRow("spCO") << QLocale(QLocale::Spanish, QLocale::Colombia) << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00));
}
void tst_QDateTime::fromStringToStringLocale()
{
+ QFETCH(QLocale, locale);
QFETCH(QDateTime, dateTime);
QLocale def;
- QLocale::setDefault(QLocale(QLocale::French, QLocale::France));
+ QLocale::setDefault(locale);
#define ROUNDTRIP(format) \
QCOMPARE(QDateTime::fromString(dateTime.toString(format), format), dateTime)