diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 0fb43b7fe8085258f655b7758d06466595c2b8d0..1078aef6ad874c86756336ac82bdb8d7d5f296fe 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -1689,6 +1689,30 @@ void tst_QDateTime::daylightSavingsTimeChange() // back again: dt = dt.addDays(-days).addSecs(60); QCOMPARE(dt, QDateTime(inDST, QTime(0, 5, 0))); + + // Now use the result of a UTC -> LocalTime conversion + dt = QDateTime(outDST, QTime(0, 0, 0), Qt::LocalTime).toUTC(); + dt = QDateTime(dt.date(), dt.time(), Qt::UTC).toLocalTime(); + QCOMPARE(dt, QDateTime(outDST, QTime(0, 0, 0))); + + // using addDays: + dt = dt.addDays(-days).addSecs(3600); + QCOMPARE(dt, QDateTime(inDST, QTime(1, 0, 0))); + // back again + dt = dt.addDays(days).addSecs(3600); + QCOMPARE(dt, QDateTime(outDST, QTime(2, 0, 0))); + + // using addMonths: + dt = dt.addMonths(-months).addSecs(3600); + QCOMPARE(dt, QDateTime(inDST, QTime(3, 0, 0))); + // back again: + dt = dt.addMonths(months).addSecs(3600); + QCOMPARE(dt, QDateTime(outDST, QTime(4, 0, 0))); + + // using setDate: + dt.setDate(inDST); + dt = dt.addSecs(3600); + QCOMPARE(dt, QDateTime(inDST, QTime(5, 0, 0))); } void tst_QDateTime::springForward_data()