diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 5ed72dd5e30..f85e4115bbd 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -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 diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index 4e2fe96442a..7815183d558 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -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")