From 348b86d976e1b433729114c3cdb29b7397a0a3d4 Mon Sep 17 00:00:00 2001 From: Marcel Krems Date: Thu, 27 Aug 2020 18:43:57 +0200 Subject: [PATCH] Fix failures in tst_qdatetime under non-english locales QDateTime::toString uses the C locale since 5ba66c5622e9e0da87a5037399b375d7e8cee554 So don't expect locale specific day- and month-names. Task-number: QTBUG-80441 Change-Id: I08f53b6b33ed9e7eaaa58df4ca6a966c4ba9ef24 Reviewed-by: Edward Welbourne --- src/corelib/time/qdatetime.cpp | 3 +-- tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 167db2bb6a..f5d0cad42f 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -4019,8 +4019,7 @@ QString QDateTime::toString(Qt::DateFormat format) const If the datetime is invalid, an empty string will be returned. \note If localized month and day names are desired, please switch to using - QLocale::system().toString() as QDateTime methods shall change to use - English (C locale) names at Qt 6. + QLocale::system().toString() as QDateTime methods use English (C locale) names. \sa fromString(), QDate::toString(), QTime::toString(), QLocale::toString() */ diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index 233a33065e..c2c0fbd7d5 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -892,8 +892,8 @@ void tst_QDateTime::toString_textDate_data() QTest::addColumn("datetime"); QTest::addColumn("expected"); - QString wednesdayJanuary = QLocale::system().dayName(3, QLocale::ShortFormat) - + ' ' + QLocale::system().monthName(1, QLocale::ShortFormat); + const QString wednesdayJanuary = QLocale::c().dayName(3, QLocale::ShortFormat) + + ' ' + QLocale::c().monthName(1, QLocale::ShortFormat); QTest::newRow("localtime") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::LocalTime) << wednesdayJanuary + QString(" 2 01:02:03 2013");