Commit e08fe31f authored by Edward Welbourne's avatar Edward Welbourne
Browse files

Add DST-change test for a date derived via .toLocalTime().


Uses a time derived via .toUTC() to ensure the .toLocalTime() comes
out at the time we expect.

Task-number: QTBUG-49008
Change-Id: I2005127929c7eab1b7a3cbaba8d21df8c9585d17
Reviewed-by: default avatarThiago Macieira <thiago.macieira@intel.com>
Showing with 24 additions and 0 deletions
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment