Correct handling of start-of-rule situations in QTZP_win
A recent change made sure the handling of a time before the first rule
would be handled correctly; but I wrongly supposed relevant code would
only be exercised in that case. However, it is also run when the
moment after which we want a transition is after the last transition
in the rule for its year: we fall through to the next rule and need to
find its first transition.
This amends commit d98b43005e.
Change-Id: Idb9114a2e272ff9cdb80312f33a0b1e6cd02d582
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
parent
aafefc094d
commit
9a0949a25b
|
|
@ -684,19 +684,21 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::nextTransition(qint64 afterMSecsSinc
|
|||
for (int ruleIndex = ruleIndexForYear(m_tranRules, year);
|
||||
ruleIndex < m_tranRules.count(); ++ruleIndex) {
|
||||
const QWinTransitionRule &rule = m_tranRules.at(ruleIndex);
|
||||
// Initial guess: rule starts in standard time (unsound in southern hemisphere).
|
||||
int newYearOffset = rule.standardTimeBias;
|
||||
// Does this rule's period include any transition at all ?
|
||||
if (rule.standardTimeRule.wMonth > 0 || rule.daylightTimeRule.wMonth > 0) {
|
||||
if (year < rule.startYear) {
|
||||
Q_ASSERT(ruleIndex == 0);
|
||||
// Find first transition in this first rule.
|
||||
// Initial guess: first rule starts in standard time.
|
||||
TransitionTimePair pair(rule, rule.startYear, rule.standardTimeBias);
|
||||
// Either before first rule's start, or we fell off the end of
|
||||
// the rule for year because afterMSecsSinceEpoch is after any
|
||||
// transitions in it. Find first transition in this rule.
|
||||
TransitionTimePair pair(rule, rule.startYear, newYearOffset);
|
||||
return pair.ruleToData(rule, this, pair.startsInDst());
|
||||
}
|
||||
const int endYear = ruleIndex + 1 < m_tranRules.count()
|
||||
? qMin(m_tranRules.at(ruleIndex + 1).startYear, year + 2) : (year + 2);
|
||||
int prior = year == 1 ? -1 : year - 1; // No year 0.
|
||||
int newYearOffset = (year <= rule.startYear && ruleIndex > 0)
|
||||
newYearOffset = (year <= rule.startYear && ruleIndex > 0)
|
||||
? yearEndOffset(m_tranRules.at(ruleIndex - 1), prior)
|
||||
: yearEndOffset(rule, prior);
|
||||
while (year < endYear) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue