tst_QDateTime::springForward(): adapt tests for midnight transitions
The second pass through each test case, going via UTC, applied an adjustment to the time; however QTime wraps around modulo the day, so applying a negative adjustment to a time too near the start of the day could produce a time at the end of the day. I'm preparing to add some test-case variants for which the transition's UTC date differs from the date in the zone doing it, which trigger this. Combine the time with the date before applying the adjustment, so that the date gets decremented to match the time's wrap-around and conversion from UTC duly gets back to the correct place, not a day later. The new test cases (in an imminent commit) thus pass. Change-Id: I1bd5f191c7673a56ac3fbfc69eab0bc03c9e40b3 Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
This commit is contained in:
parent
c888153655
commit
79340518d7
@ -2262,10 +2262,10 @@ void tst_QDateTime::springForward()
|
||||
// Note: function doc claims always +1, but this should be reviewed !
|
||||
}
|
||||
|
||||
// Repeat, but getting there via .toTimeZone():
|
||||
QDateTime detour = QDateTime(day.addDays(-step),
|
||||
time.addSecs(-60 * adjust),
|
||||
UTC).toTimeZone(zone);
|
||||
// Repeat, but getting there via .toTimeZone(). Apply adjust to datetime,
|
||||
// not time, as the time wraps round if the adjustment crosses midnight.
|
||||
QDateTime detour = QDateTime(day.addDays(-step), time,
|
||||
UTC).addSecs(-60 * adjust).toTimeZone(zone);
|
||||
QCOMPARE(detour.time(), time);
|
||||
detour = detour.addDays(step);
|
||||
// Insist on consistency:
|
||||
|
Loading…
Reference in New Issue
Block a user