diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-09-24 14:12:04 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-10-12 22:52:50 +0200 |
commit | ba23507960a80367d918468d9d7da39c92a09fbf (patch) | |
tree | 21881db6c9d5e0d95e3e3bb76d45cbff68f3d7b2 /tests | |
parent | 22e330db482672b56fa8292b0649935de375e82e (diff) |
Fix handling of time-zone gap in QTimeZonePrivate::dataForLocalTime()
This was handled correctly when the backend supplies transitions
bracketing the time in question, but the fallback code tried to use
the DST offset at the time with larger offset from UTC; this did not
work when the gap was due to a change in standard time. Discovered by
ANS1 parsing of a date-time with two-digit year, for which the
date-time parser tried to use 1921-05-01T00:00 local time when filling
in the fields it had parsed; but, when run in Europe/Helsinki, there
is no such time due to the 20m 11s skipped when joining EET from the
prior local solar mean time.
Correct the calculation to use the actual change in offset from UTC,
as used in the (far better tested) between-transitions branch of the
code, rather than the DST offset after the transition.
Add a test-case based on the ASN.1 certificate date whose parsing
revealed the issue. Although it seems nothing in Coin can reproduce
the issue, the reporter has verified that the test does indeed fail on
the system where the bug was found and the fix does fix it.
Fixes: QTBUG-96861
Pick-to: 6.2
Change-Id: I12b02bad01daca2073d1a356452cd573684aa688
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index cb93439bad..ef0be8a97c 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -2926,6 +2926,18 @@ void tst_QDateTime::fromStringStringFormat_localTimeZone_data() << QString("2008-10-13 GMT 11.50") << QString("yyyy-MM-dd t hh.mm") << QDateTime(QDate(2008, 10, 13), QTime(11, 50), gmt); } + QTimeZone helsinki("Europe/Helsinki"); + if (helsinki.isValid()) { + // QTBUG-96861: QAsn1Element::toDateTime() tripped over an assert in + // QTimeZonePrivate::dataForLocalTime() on macOS and iOS. + // The first 20m 11s of 1921-05-01 were skipped, so the parser's attempt + // to construct a local time after scanning yyMM tripped up on the start + // of the day, when the zone backend lacked transition data. + QTest::newRow("Helsinki-joins-EET") + << QByteArrayLiteral("Europe/Helsinki") + << QString("210506000000Z") << QString("yyMMddHHmmsst") + << QDateTime(QDate(1921, 5, 6), QTime(0, 0), Qt::UTC); + } #endif } |