Add test creating QDateTime in double-DST gap in 1947 Germany

In 1947, Germany had not only a summer time but also a
"Hochsommerzeit", a high summer time. This patch adds a test
creating a QDateTime in the time gap at the beginning of this
Hochsommerzeit on May 11, 1947.

Pick-to: 6.0
Change-Id: Ib81a23914965f092c3e3195e4c7258e5a4e0b30e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Andreas Buhr 2020-11-30 20:19:12 +01:00
parent 41e665a452
commit 741862875c
2 changed files with 12 additions and 0 deletions

View File

@ -3204,6 +3204,9 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT
Q_ASSERT((zoneMSecs - data.atMSecsSinceEpoch) / 1000 == data.offsetFromUtc
// If zoneMSecs fell in a spring-forward's gap, we get this instead:
|| (zoneMSecs - data.atMSecsSinceEpoch) / 1000 == data.standardTimeOffset
// If we have a second DST, like in Europe/Berlin 1947 (mid-summer time).
// If zoneMSecs fell in a gap at beginning of mid-summer time, we get this instead:
|| (zoneMSecs - data.atMSecsSinceEpoch) / 1000 == 2 * data.standardTimeOffset
// If it fell in a skipped day (Pacific date-line crossings), this happens:
|| (data.offsetFromUtc - (zoneMSecs - data.atMSecsSinceEpoch) / 1000) % 86400 == 0);
// Docs state any time before 1970-01-01 will *not* have any DST applied

View File

@ -2775,6 +2775,15 @@ void tst_QDateTime::fromStringStringFormat_data()
// That's in the hour skipped - expect the matching time after the spring-forward, in DST:
<< QDateTime(QDate(2008, 10, 19), QTime(1, 23, 45, 678), southBrazil);
}
QTimeZone berlintz("Europe/Berlin");
if (berlintz.isValid()) {
QTest::newRow("begin-of-high-summer-time-with-tz")
<< QString("1947-05-11 03:23:45.678 Europe/Berlin")
<< QString("yyyy-MM-dd hh:mm:ss.zzz t")
// That's in the hour skipped - expecting an invalid DateTime
<< QDateTime(QDate(1947, 05, 11), QTime(3, 23, 45, 678), berlintz);
}
#endif
QTest::newRow("late") << QString("9999-12-31T23:59:59.999Z")
<< QString("yyyy-MM-ddThh:mm:ss.zZ")