summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-02-24 12:01:29 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-03-04 23:26:12 +0100
commit8a52555d3fdecae11955dada101f91dc96bc865f (patch)
tree05691b6ee13d14b01ce8556e6b000fb967f3e50c /src/corelib
parent0efebf168d11a41a7b213520405ff944eb93bb10 (diff)
Fix handling of out-of-range years in QTZP_win
A transition outside the range of qint64 would be mapped to invalidMSecs(), the same as the fake-detection sets a fake transition to. This would have lead to a year at the boundary of qint64's range being mistaken for a fake-DST year. So replace the fakesDst() method, that compared transition times to invalidMSecs(), with an actual boolean member that gets set when detecting fake DST, so that the detection is correctly done. Pick-to: 6.3 Change-Id: Iadc80973bc033915733c4a4f4ccfdd3863025fb4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/time/qtimezoneprivate_win.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp
index 25a2ba5a39..d71508a806 100644
--- a/src/corelib/time/qtimezoneprivate_win.cpp
+++ b/src/corelib/time/qtimezoneprivate_win.cpp
@@ -344,6 +344,7 @@ struct TransitionTimePair
qint64 std, dst;
// If either is invalidMSecs(), which shall then be < the other, there is no
// DST and the other describes a change in actual standard offset.
+ bool fakesDst = false;
TransitionTimePair(const QWinTimeZonePrivate::QWinTransitionRule &rule,
int year, int oldYearOffset)
@@ -401,19 +402,17 @@ struct TransitionTimePair
if (rule.standardTimeBias + rule.daylightTimeBias == oldYearOffset
&& isAtStartOfYear(rule.daylightTimeRule, year)) {
dst = QTimeZonePrivate::invalidMSecs();
+ fakesDst = true;
}
if (rule.standardTimeBias == oldYearOffset
&& isAtStartOfYear(rule.standardTimeRule, year)) {
+ Q_ASSERT_X(!fakesDst, "TransitionTimePair",
+ "Year with (DST bias zero and) both transitions fake !");
std = QTimeZonePrivate::invalidMSecs();
+ fakesDst = true;
}
}
- bool fakesDst() const
- {
- return std == QTimeZonePrivate::invalidMSecs()
- || dst == QTimeZonePrivate::invalidMSecs();
- }
-
bool startsInDst() const
{
// Year starts in daylightTimeRule iff it has a valid transition out of
@@ -428,9 +427,9 @@ struct TransitionTimePair
auto time = isDst ? dst : std;
// The isDst we're asked for may be set to the valid one of dst and
// std, when fake, but not always - so make sure:
- if (time == QTimeZonePrivate::invalidMSecs())
+ if (fakesDst && time == QTimeZonePrivate::invalidMSecs())
time = isDst ? std : dst;
- return tzp->ruleToData(rule, time, type, fakesDst());
+ return tzp->ruleToData(rule, time, type, fakesDst);
}
};
@@ -681,7 +680,7 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons
}
return ruleToData(rule, forMSecsSinceEpoch,
isDst ? QTimeZone::DaylightTime : QTimeZone::StandardTime,
- pair.fakesDst());
+ pair.fakesDst);
}
// Fell off start of rule, try previous rule.
} else {