diff options
author | unknown <jlayt@kde.org> | 2013-11-11 18:22:25 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-21 09:25:23 +0100 |
commit | c03ea9be38a3c23b54e56bb567205a02ad4d1e19 (patch) | |
tree | 83391f3c3d79018984e63a2785db78e4bda39d31 /src/corelib/tools/qtimezoneprivate_win.cpp | |
parent | 6bf759b31040fb5d05044cd14d5889fbd19a8942 (diff) |
QTimeZone - Fix Windows Transitions with null rules
Fix the Windows handling of null DST rules for a given year, if the
calculation rules have a null value then can skip trying to loop through
the calculations until the min/max year is hit which causes the stress
test to time-out in CI, and instead return a value immediately.
Change-Id: Ie2d4ee55c5487e040e0cead91d1be2a0c06d3074
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qtimezoneprivate_win.cpp')
-rw-r--r-- | src/corelib/tools/qtimezoneprivate_win.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp index 55949128ae..04588b2ba8 100644 --- a/src/corelib/tools/qtimezoneprivate_win.cpp +++ b/src/corelib/tools/qtimezoneprivate_win.cpp @@ -305,7 +305,7 @@ static void calculateTransitionsForYear(const QWinTimeZonePrivate::QWinTransitio QDate daylightDate = calculateTransitionLocalDate(rule.daylightTimeRule, year); QTime daylightTime = QTime(rule.daylightTimeRule.wHour, rule.daylightTimeRule.wMinute, rule.daylightTimeRule.wSecond); - if (standardDate.isValid() && standardTime.isValid()) + if (daylightDate.isValid() && daylightTime.isValid()) *dstMSecs = timeToMSecs(daylightDate, daylightTime) + (rule.standardTimeBias * 60000); else *dstMSecs = QTimeZonePrivate::invalidMSecs(); @@ -488,6 +488,9 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons do { // Convert the transition rules into msecs for the year we want to try rule = ruleForYear(year); + // If no transition rules to calculate then no DST, so just use rule for std + if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0) + break; calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs); if (stdMSecs < dstMSecs) { first = stdMSecs; @@ -543,6 +546,9 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::nextTransition(qint64 afterMSecsSinc do { // Convert the transition rules into msecs for the year we want to try rule = ruleForYear(year); + // If no transition rules to calculate then no next transition + if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0) + return invalidData(); calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs); // Find the first and second transition for the year if (stdMSecs < dstMSecs) { @@ -591,6 +597,9 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSec do { // Convert the transition rules into msecs for the year we want to try rule = ruleForYear(year); + // If no transition rules to calculate then no previous transition + if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0) + return invalidData(); calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs); if (stdMSecs < dstMSecs) { first = stdMSecs; |