summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-02-12 13:26:37 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2021-02-15 13:44:21 +0100
commit517578e0712732ad43f21b6a655ba5e70ada6ab7 (patch)
treef9b42b3cb43ca7c5a0090abf264169dec3445b79 /tests/auto
parent3cf84287e71d8698c46ce31a6daad71056db8027 (diff)
QDateTime::toString(): use UTC-offset as time-zone suffix
Since fromString() can't parse the (ambiguous at the best of times; also backend-dependent and thus potentially system-locale-dependent) abbreviations currently produced (since 5.9) and can parse UTC-based offsets, the OffsetName of the zone is a more robust format for the zone-suffix. This also makes it possible to consistently use the C locale, compatibly with everything else about post-6.0 date-time serialization. [ChangeLog][QtCore][QDateTime] When spec is Qt::TimeZone, the offset-suffix now used for the toString(Qt::TextDate) format is now a UTC-based offset string, compatible with the parsing (now) supported by fromString(). The zone-abbreviation suffix in use since 5.9 was not parseable. Change-Id: I4024ae87980c6d3590c68a67b8d1c8f433e36855 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index 4bf78cb93a..2bf93c3ce0 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -940,9 +940,6 @@ void tst_QDateTime::toString_textDate_extra()
QVERIFY(!endsWithGmt(dt));
#if QT_CONFIG(timezone)
-# if defined Q_OS_UNIX && !defined Q_OS_DARWIN && !defined Q_OS_ANDROID
-# define CORRECT_ZONE_ABBREV
-# endif // QTBUG-57320, QTBUG-57298, QTBUG-68833
if (QTimeZone::systemTimeZone().offsetFromUtc(dt))
QVERIFY(dt.toString() != QLatin1String("Thu Jan 1 00:00:00 1970"));
else
@@ -951,11 +948,7 @@ void tst_QDateTime::toString_textDate_extra()
QTimeZone PST("America/Vancouver");
if (PST.isValid()) {
dt = QDateTime::fromMSecsSinceEpoch(0, PST);
-# ifdef CORRECT_ZONE_ABBREV
- QCOMPARE(dt.toString(), QLatin1String("Wed Dec 31 16:00:00 1969 PST"));
-# else
- QVERIFY(dt.toString().startsWith(QLatin1String("Wed Dec 31 16:00:00 1969 ")));
-# endif
+ QCOMPARE(dt.toString(), QLatin1String("Wed Dec 31 16:00:00 1969 UTC-08:00"));
dt = dt.toLocalTime();
QVERIFY(!endsWithGmt(dt));
} else {
@@ -964,11 +957,7 @@ void tst_QDateTime::toString_textDate_extra()
QTimeZone CET("Europe/Berlin");
if (CET.isValid()) {
dt = QDateTime::fromMSecsSinceEpoch(0, CET);
-# ifdef CORRECT_ZONE_ABBREV
- QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 01:00:00 1970 CET"));
-# else
- QVERIFY(dt.toString().startsWith(QLatin1String("Thu Jan 1 01:00:00 1970 ")));
-# endif
+ QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 01:00:00 1970 UTC+01:00"));
dt = dt.toLocalTime();
QVERIFY(!endsWithGmt(dt));
} else {