summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-02-14 15:19:46 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-03-10 13:42:34 +0100
commit74add7957dfb9dfcd797c697b26c3abd34d216d1 (patch)
tree0b06f4996d9d08a5de12783a155323c57b0fe7c3
parentdfa7907c5205730a529a03ca6d7fa527f2b00d68 (diff)
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 d98b43005eed051a77beacb252c7a9eb7f5c4493. Change-Id: Idb9114a2e272ff9cdb80312f33a0b1e6cd02d582 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 9a0949a25b647aa9fc4f03d85e2f0f22cf1289ce) Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r--src/corelib/time/qtimezoneprivate_win.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp
index bf9bcd51d0..7ccad273ad 100644
--- a/src/corelib/time/qtimezoneprivate_win.cpp
+++ b/src/corelib/time/qtimezoneprivate_win.cpp
@@ -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) {