summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qnamespace.h20
-rw-r--r--src/corelib/global/qnamespace.qdoc54
-rw-r--r--src/corelib/text/qlocale.cpp6
-rw-r--r--src/corelib/time/qdatetime.cpp113
-rw-r--r--tests/auto/corelib/time/qdate/tst_qdate.cpp4
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp17
-rw-r--r--tests/auto/corelib/time/qtime/tst_qtime.cpp6
7 files changed, 139 insertions, 81 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 8f40393a7e..ea2c635303 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -1267,14 +1267,16 @@ public:
enum DateFormat {
TextDate, // default Qt
ISODate, // ISO 8601
- SystemLocaleDate, // deprecated
- LocalDate = SystemLocaleDate, // deprecated
- LocaleDate, // deprecated
- SystemLocaleShortDate,
- SystemLocaleLongDate,
- DefaultLocaleShortDate,
- DefaultLocaleLongDate,
- RFC2822Date, // RFC 2822 (+ 850 and 1036 during parsing)
+#if QT_DEPRECATED_SINCE(5, 15)
+ SystemLocaleDate Q_DECL_ENUMERATOR_DEPRECATED_X("Use QLocale"),
+ LocalDate Q_DECL_ENUMERATOR_DEPRECATED_X("Use QLocale") = 2, // i.e. SystemLocaleDate
+ LocaleDate Q_DECL_ENUMERATOR_DEPRECATED_X("Use QLocale"),
+ SystemLocaleShortDate Q_DECL_ENUMERATOR_DEPRECATED_X("Use QLocale"),
+ SystemLocaleLongDate Q_DECL_ENUMERATOR_DEPRECATED_X("Use QLocale"),
+ DefaultLocaleShortDate Q_DECL_ENUMERATOR_DEPRECATED_X("Use QLocale"),
+ DefaultLocaleLongDate Q_DECL_ENUMERATOR_DEPRECATED_X("Use QLocale"),
+#endif
+ RFC2822Date = 8, // RFC 2822 (+ 850 and 1036 during parsing)
ISODateWithMs
};
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 9acb978efc..8debee7bb5 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -709,26 +709,38 @@
\value ISODateWithMs \l{ISO 8601} extended format, including milliseconds if applicable.
- \value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used
- by the \l{QLocale::system()}{operating system}.
-
- \value SystemLocaleLongDate The \l{QLocale::LongFormat}{long format} used
- by the \l{QLocale::system()}{operating system}.
-
- \value DefaultLocaleShortDate The \l{QLocale::ShortFormat}{short format} specified
- by the \l{QLocale::setDefault()}{application's locale}.
-
- \value DefaultLocaleLongDate The \l{QLocale::LongFormat}{long format} used
- by the \l{QLocale::setDefault()}{application's locale}.
-
- \value SystemLocaleDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate
- instead (or Qt::SystemLocaleLongDate if you want long dates).
-
- \value LocaleDate \e{This enum value is deprecated.} Use Qt::DefaultLocaleShortDate
- instead (or Qt::DefaultLocaleLongDate if you want long dates).
-
- \value LocalDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate
- instead (or Qt::SystemLocaleLongDate if you want long dates).
+ \value SystemLocaleShortDate \e{This enum value is deprecated and
+ shall be removed in Qt 6.} Use QLocale's methods for converting
+ dates and times to and from strings, with the
+ \l{QLocale::ShortFormat}{short format} of
+ \l{QLocale::system()}{the locale used by the operating system}.
+
+ \value SystemLocaleLongDate \e{This enum value is deprecated and
+ shall be removed in Qt 6.} Use QLocale's methods for converting
+ dates and times to and from strings, with the
+ \l{QLocale::LongFormat}{long format} of \l{QLocale::system()}{the
+ locale used by the operating system}.
+
+ \value DefaultLocaleShortDate \e{This enum value is deprecated and
+ shall be removed in Qt 6.} Use QLocale's methods for converting
+ dates and times to and from strings, with the
+ \l{QLocale::ShortFormat}{short format} of
+ \l{QLocale::setDefault()}{the application's locale}.
+
+ \value DefaultLocaleLongDate \e{This enum value is deprecated and
+ shall be removed in Qt 6.} Use QLocale's methods for converting
+ dates and times to and from strings, with the
+ \l{QLocale::LongFormat}{long format} \l{QLocale::setDefault()}{the
+ application's locale}.
+
+ \value SystemLocaleDate \e{This enum value is deprecated and shall
+ be removed in Qt 6.} It is equivalent to SystemLocaleShortDate.
+
+ \value LocaleDate \e{This enum value is deprecated and shall be
+ removed in Qt 6.} It is equivalent to DefaultLocaleShortDate.
+
+ \value LocalDate \e{This enum value is deprecated and shall be
+ removed in Qt 6.} It is equivalent to SystemLocaleShortDate.
\value RFC2822Date \l{RFC 2822}, \l{RFC 850} and \l{RFC 1036} format:
either \c{[ddd,] dd MMM yyyy [hh:mm[:ss]][ ±tzoff]}
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 6dbec8ba33..022c770ac3 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -2025,6 +2025,9 @@ QString QLocale::toString(const QDate &date, QStringView format) const
/*!
Returns a localized string representation of the given \a date according
to the specified \a format.
+
+ \note Some locales may use formats that limit the range of years they can
+ represent.
*/
QString QLocale::toString(const QDate &date, FormatType format) const
@@ -2179,6 +2182,9 @@ QString QLocale::toString(const QDateTime &dateTime, QStringView format, QCalend
Returns a localized string representation of the given \a dateTime according
to the specified \a format.
+
+ \note Some locales may use formats that limit the range of years they can
+ represent.
*/
QString QLocale::toString(const QDateTime &dateTime, FormatType format) const
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 94306345da..a1cc719995 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -1150,18 +1150,16 @@ static QString toStringIsoDate(const QDate &date)
year, MM is the month of the year (between 01 and 12), and dd is
the day of the month between 01 and 31.
- If the \a format is Qt::SystemLocaleShortDate or
- Qt::SystemLocaleLongDate, the string format depends on the locale
- settings of the system. Identical to calling
- QLocale::system().toString(date, QLocale::ShortFormat) or
- QLocale::system().toString(date, QLocale::LongFormat).
-
- If the \a format is Qt::DefaultLocaleShortDate or
- Qt::DefaultLocaleLongDate, the string format depends on the
- default application locale. This is the locale set with
- QLocale::setDefault(), or the system locale if no default locale
- has been set. Identical to calling
- \l {QLocale::toString()}{QLocale().toString(date, QLocale::ShortFormat) } or
+ The \a format options Qt::SystemLocaleDate, Qt::SystemLocaleShortDate and
+ Qt::SystemLocaleLongDate shall be removed in Qt 6. Their use should be
+ replaced with
+ \l {QLocale::toString()}{QLocale::system().toString(date, QLocale::ShortFormat)} or
+ \l {QLocale::toString()}{QLocale::system().toString(date, QLocale::LongFormat)}.
+
+ The \a format options Qt::LocaleDate, Qt::DefaultLocaleShortDate and
+ Qt::DefaultLocaleLongDate shall be removed in Qt 6. Their use should be
+ replaced with
+ \l {QLocale::toString()}{QLocale().toString(date, QLocale::ShortFormat)} or
\l {QLocale::toString()}{QLocale().toString(date, QLocale::LongFormat)}.
If the \a format is Qt::RFC2822Date, the string is formatted in
@@ -1171,8 +1169,7 @@ static QString toStringIsoDate(const QDate &date)
If the date is invalid, an empty string will be returned.
\warning The Qt::ISODate format is only valid for years in the
- range 0 to 9999. This restriction may apply to locale-aware
- formats as well, depending on the locale settings.
+ range 0 to 9999.
\sa fromString(), QLocale::toString()
*/
@@ -1182,6 +1179,7 @@ QString QDate::toString(Qt::DateFormat format) const
return QString();
switch (format) {
+#if QT_DEPRECATED_SINCE(5, 15)
case Qt::SystemLocaleDate:
case Qt::SystemLocaleShortDate:
return QLocale::system().toString(*this, QLocale::ShortFormat);
@@ -1192,6 +1190,7 @@ QString QDate::toString(Qt::DateFormat format) const
return QLocale().toString(*this, QLocale::ShortFormat);
case Qt::DefaultLocaleLongDate:
return QLocale().toString(*this, QLocale::LongFormat);
+#endif // 5.15
case Qt::RFC2822Date:
return QLocale::c().toString(*this, u"dd MMM yyyy");
default:
@@ -1284,6 +1283,7 @@ QString QDate::toString(Qt::DateFormat format, QCalendar cal) const
return QString();
switch (format) {
+#if QT_DEPRECATED_SINCE(5, 15)
case Qt::SystemLocaleDate:
case Qt::SystemLocaleShortDate:
return QLocale::system().toString(*this, QLocale::ShortFormat, cal);
@@ -1294,6 +1294,7 @@ QString QDate::toString(Qt::DateFormat format, QCalendar cal) const
return QLocale().toString(*this, QLocale::ShortFormat, cal);
case Qt::DefaultLocaleLongDate:
return QLocale().toString(*this, QLocale::LongFormat, cal);
+#endif // 5.15
case Qt::RFC2822Date:
return QLocale::c().toString(*this, QStringView(u"dd MMM yyyy"), cal);
default:
@@ -1659,9 +1660,14 @@ ParsedInt readInt(QStringView text)
\a format given, or an invalid date if the string cannot be
parsed.
- Note for Qt::TextDate: It is recommended that you use the
- English short month names (e.g. "Jan"). Although localized month
- names can also be used, they depend on the user's locale settings.
+ Note for Qt::TextDate: It is recommended that you use the English short
+ month names (e.g. "Jan"). Although localized month names can also be used in
+ Qt 5, they depend on the user's locale settings.
+
+ \note Support for localized dates, including the format options
+ Qt::SystemLocaleDate, Qt::SystemLocaleShortDate, Qt::SystemLocaleLongDate,
+ Qt::LocaleDate, Qt::DefaultLocaleShortDate, and Qt::DefaultLocaleLongDate,
+ shall be removed in Qt 6. Use QLocale::toDate() instead.
\sa toString(), QLocale::toDate()
*/
@@ -1672,6 +1678,7 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format)
return QDate();
switch (format) {
+#if QT_DEPRECATED_SINCE(5, 15)
case Qt::SystemLocaleDate:
case Qt::SystemLocaleShortDate:
return QLocale::system().toDate(string, QLocale::ShortFormat);
@@ -1682,6 +1689,7 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format)
return QLocale().toDate(string, QLocale::ShortFormat);
case Qt::DefaultLocaleLongDate:
return QLocale().toDate(string, QLocale::LongFormat);
+#endif // 5.15
case Qt::RFC2822Date:
return rfcDateImpl(string).date;
default:
@@ -2035,18 +2043,15 @@ int QTime::msec() const
date, use the \a format Qt::ISODateWithMs, which corresponds to
HH:mm:ss.zzz.
- If the \a format is Qt::SystemLocaleShortDate or
- Qt::SystemLocaleLongDate, the string format depends on the locale
- settings of the system. Identical to calling
- QLocale::system().toString(time, QLocale::ShortFormat) or
- QLocale::system().toString(time, QLocale::LongFormat).
-
- If the \a format is Qt::DefaultLocaleShortDate or
- Qt::DefaultLocaleLongDate, the string format depends on the
- default application locale. This is the locale set with
- QLocale::setDefault(), or the system locale if no default locale
- has been set. Identical to calling
+ The \a format options Qt::SystemLocaleDate:, Qt::SystemLocaleShortDate and
+ Qt::SystemLocaleLongDate shall be removed in Qt 6. Their use should be
+ replaced with:
+ \l {QLocale::toString()}{QLocale::system().toString(time, QLocale::ShortFormat)} or
+ \l {QLocale::toString()}{QLocale::system().toString(time, QLocale::LongFormat)}.
+ The \a format options Qt::LocaleDate, Qt::DefaultLocaleShortDate and
+ Qt::DefaultLocaleLongDate shall be removed in Qt 6. Their use should be
+ replaced with:
\l {QLocale::toString()}{QLocale().toString(time, QLocale::ShortFormat)} or
\l {QLocale::toString()}{QLocale().toString(time, QLocale::LongFormat)}.
@@ -2065,6 +2070,7 @@ QString QTime::toString(Qt::DateFormat format) const
return QString();
switch (format) {
+#if QT_DEPRECATED_SINCE(5, 15)
case Qt::SystemLocaleDate:
case Qt::SystemLocaleShortDate:
return QLocale::system().toString(*this, QLocale::ShortFormat);
@@ -2075,6 +2081,7 @@ QString QTime::toString(Qt::DateFormat format) const
return QLocale().toString(*this, QLocale::ShortFormat);
case Qt::DefaultLocaleLongDate:
return QLocale().toString(*this, QLocale::LongFormat);
+#endif // 5.15
case Qt::ISODateWithMs:
return QString::asprintf("%02d:%02d:%02d.%03d", hour(), minute(), second(), msec());
case Qt::RFC2822Date:
@@ -2450,6 +2457,12 @@ static QTime fromIsoTimeString(QStringView string, Qt::DateFormat format, bool *
fails for the default locale). This should be considered an
implementation detail.
+
+ \note Support for localized dates, including the format options
+ Qt::SystemLocaleDate, Qt::SystemLocaleShortDate, Qt::SystemLocaleLongDate,
+ Qt::LocaleDate, Qt::DefaultLocaleShortDate, and Qt::DefaultLocaleLongDate,
+ shall be removed in Qt 6. Use QLocale::toTime() instead.
+
\sa toString(), QLocale::toTime()
*/
QTime QTime::fromString(const QString &string, Qt::DateFormat format)
@@ -2458,6 +2471,7 @@ QTime QTime::fromString(const QString &string, Qt::DateFormat format)
return QTime();
switch (format) {
+#if QT_DEPRECATED_SINCE(5, 15)
case Qt::SystemLocaleDate:
case Qt::SystemLocaleShortDate:
return QLocale::system().toTime(string, QLocale::ShortFormat);
@@ -2468,6 +2482,7 @@ QTime QTime::fromString(const QString &string, Qt::DateFormat format)
return QLocale().toTime(string, QLocale::ShortFormat);
case Qt::DefaultLocaleLongDate:
return QLocale().toTime(string, QLocale::LongFormat);
+#endif // 5.15
case Qt::RFC2822Date:
return rfcDateImpl(string).time;
case Qt::ISODate:
@@ -4326,19 +4341,17 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
date, use the \a format Qt::ISODateWithMs, which corresponds to
yyyy-MM-ddTHH:mm:ss.zzz[Z|[+|-]HH:mm].
- If the \a format is Qt::SystemLocaleShortDate or
- Qt::SystemLocaleLongDate, the string format depends on the locale
- settings of the system. Identical to calling
- QLocale::system().toString(datetime, QLocale::ShortFormat) or
- QLocale::system().toString(datetime, QLocale::LongFormat).
+ The \a format options Qt::SystemLocaleDate, Qt::SystemLocaleShortDate and
+ Qt::SystemLocaleLongDate shall be removed in Qt 6. Their use should be
+ replaced with
+ \l {QLocale::toString()}{QLocale::system().toString(datetime, QLocale::ShortFormat)} or
+ \l {QLocale::toString()}{QLocale::system().toString(datetime, QLocale::LongFormat)}.
- If the \a format is Qt::DefaultLocaleShortDate or
- Qt::DefaultLocaleLongDate, the string format depends on the
- default application locale. This is the locale set with
- QLocale::setDefault(), or the system locale if no default locale
- has been set. Identical to calling QLocale().toString(datetime,
- QLocale::ShortFormat) or QLocale().toString(datetime,
- QLocale::LongFormat).
+ The \a format options Qt::LocaleDate, Qt::DefaultLocaleShortDate and
+ Qt::DefaultLocaleLongDate shall be removed in Qt 6. Their use should be
+ replaced with
+ \l {QLocale::toString()}{QLocale().toString(datetime, QLocale::ShortFormat)} or
+ \l {QLocale::toString()}{QLocale().toString(datetime, QLocale::LongFormat)}.
If the \a format is Qt::RFC2822Date, the string is formatted
following \l{RFC 2822}.
@@ -4346,8 +4359,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
If the datetime is invalid, an empty string will be returned.
\warning The Qt::ISODate format is only valid for years in the
- range 0 to 9999. This restriction may apply to locale-aware
- formats as well, depending on the locale settings.
+ range 0 to 9999.
\sa fromString(), QDate::toString(), QTime::toString(),
QLocale::toString()
@@ -4365,6 +4377,7 @@ QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) const
return buf;
switch (format) {
+#if QT_DEPRECATED_SINCE(5, 15)
case Qt::SystemLocaleDate:
case Qt::SystemLocaleShortDate:
return QLocale::system().toString(*this, QLocale::ShortFormat, cal);
@@ -4375,6 +4388,7 @@ QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) const
return QLocale().toString(*this, QLocale::ShortFormat, cal);
case Qt::DefaultLocaleLongDate:
return QLocale().toString(*this, QLocale::LongFormat, cal);
+#endif // 5.15
case Qt::RFC2822Date: {
buf = QLocale::c().toString(*this, u"dd MMM yyyy hh:mm:ss ", cal);
buf += toOffsetString(Qt::TextDate, offsetFromUtc());
@@ -5239,9 +5253,14 @@ int QDateTime::utcOffset() const
Returns the QDateTime represented by the \a string, using the
\a format given, or an invalid datetime if this is not possible.
- Note for Qt::TextDate: It is recommended that you use the
- English short month names (e.g. "Jan"). Although localized month
- names can also be used, they depend on the user's locale settings.
+ Note for Qt::TextDate: It is recommended that you use the English short
+ month names (e.g. "Jan"). Although localized month names can also be used in
+ Qt 5, they depend on the user's locale settings.
+
+ \note Support for localized dates, including the format options
+ Qt::SystemLocaleDate, Qt::SystemLocaleShortDate, Qt::SystemLocaleLongDate,
+ Qt::LocaleDate, Qt::DefaultLocaleShortDate, and Qt::DefaultLocaleLongDate,
+ shall be removed in Qt 6. Use QLocale::toDateTime() instead.
\sa toString(), QLocale::toDateTime()
*/
@@ -5251,6 +5270,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
return QDateTime();
switch (format) {
+#if QT_DEPRECATED_SINCE(5, 15)
case Qt::SystemLocaleDate:
case Qt::SystemLocaleShortDate:
return QLocale::system().toDateTime(string, QLocale::ShortFormat);
@@ -5261,6 +5281,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
return QLocale().toDateTime(string, QLocale::ShortFormat);
case Qt::DefaultLocaleLongDate:
return QLocale().toDateTime(string, QLocale::LongFormat);
+#endif // 5.15
case Qt::RFC2822Date: {
const ParsedRfcDateTime rfc = rfcDateImpl(string);
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp
index 567209dcf6..274bf4f6f0 100644
--- a/tests/auto/corelib/time/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -1352,6 +1352,7 @@ void tst_QDate::toStringDateFormat()
QFETCH(Qt::DateFormat, format);
QFETCH(QString, expectedStr);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat));
QCOMPARE(date.toString(Qt::DefaultLocaleShortDate), QLocale().toString(date, QLocale::ShortFormat));
QCOMPARE(date.toString(Qt::SystemLocaleLongDate), QLocale::system().toString(date, QLocale::LongFormat));
@@ -1361,6 +1362,7 @@ void tst_QDate::toStringDateFormat()
QCOMPARE(date.toString(Qt::DefaultLocaleShortDate), QLocale().toString(date, QLocale::ShortFormat));
QCOMPARE(date.toString(Qt::SystemLocaleLongDate), QLocale::system().toString(date, QLocale::LongFormat));
QCOMPARE(date.toString(Qt::DefaultLocaleLongDate), QLocale().toString(date, QLocale::LongFormat));
+#endif // ### Qt 6: remove
QCOMPARE(date.toString(format), expectedStr);
}
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index ec5f65ee56..26ad91271d 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -127,8 +127,10 @@ private slots:
#ifdef Q_OS_WIN
void fromString_LOCALE_ILDATE();
#endif
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void fromStringToStringLocale_data();
void fromStringToStringLocale();
+#endif // ### Qt 6: remove
void offsetFromUtc();
void setOffsetFromUtc();
@@ -295,9 +297,9 @@ void tst_QDateTime::initTestCase()
void tst_QDateTime::init()
{
-#if defined(Q_OS_WIN32)
+#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
-#endif
+#endif // ### Qt 6: remove
}
QString tst_QDateTime::str( int y, int month, int d, int h, int min, int s )
@@ -834,8 +836,10 @@ void tst_QDateTime::toString_isoDate()
QFETCH(Qt::DateFormat, format);
QFETCH(QString, expected);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QLocale oldLocale;
QLocale::setDefault(QLocale("en_US"));
+#endif // ### Qt 6: remove
QString result = datetime.toString(format);
QCOMPARE(result, expected);
@@ -854,7 +858,9 @@ void tst_QDateTime::toString_isoDate()
QCOMPARE(resultDatetime, QDateTime());
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QLocale::setDefault(oldLocale);
+#endif // ### Qt 6: remove
}
void tst_QDateTime::toString_isoDate_extra()
@@ -1763,7 +1769,7 @@ void tst_QDateTime::daylightSavingsTimeChange()
// because some functions did not reset the flag when moving in or out of DST.
// WARNING: This only tests anything if there's a Daylight Savings Time change
- // in the current locale between inDST and outDST.
+ // in the current time-zone between inDST and outDST.
// This is true for Central European Time and may be elsewhere.
QFETCH(QDate, inDST);
@@ -2612,6 +2618,9 @@ void tst_QDateTime::fromString_LOCALE_ILDATE()
}
#endif
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED
+
void tst_QDateTime::fromStringToStringLocale_data()
{
QTest::addColumn<QLocale>("locale");
@@ -2643,6 +2652,8 @@ void tst_QDateTime::fromStringToStringLocale()
#undef ROUNDTRIP
QLocale::setDefault(def);
}
+QT_WARNING_POP
+#endif // ### Qt 6: remove
void tst_QDateTime::offsetFromUtc()
{
diff --git a/tests/auto/corelib/time/qtime/tst_qtime.cpp b/tests/auto/corelib/time/qtime/tst_qtime.cpp
index f85e0ea74e..027232f6d5 100644
--- a/tests/auto/corelib/time/qtime/tst_qtime.cpp
+++ b/tests/auto/corelib/time/qtime/tst_qtime.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -77,7 +77,9 @@ private slots:
void toStringDateFormat();
void toStringFormat_data();
void toStringFormat();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void toStringLocale();
+#endif // ### Qt 6: remove
void msecsSinceStartOfDay_data();
void msecsSinceStartOfDay();
@@ -770,6 +772,7 @@ void tst_QTime::toStringFormat()
QCOMPARE( t.toString( format ), str );
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void tst_QTime::toStringLocale()
{
QTime time(18, 30);
@@ -791,6 +794,7 @@ void tst_QTime::toStringLocale()
QCOMPARE(time.toString(Qt::DefaultLocaleLongDate),
QLocale().toString(time, QLocale::LongFormat));
}
+#endif // ### Qt 6: remove
void tst_QTime::msecsSinceStartOfDay_data()
{