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>bb10
parent
0efebf168d
commit
8a52555d3f
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue