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>
This commit is contained in:
unknown 2013-11-11 18:22:25 +01:00 committed by The Qt Project
parent 6bf759b310
commit c03ea9be38

View File

@ -305,7 +305,7 @@ static void calculateTransitionsForYear(const QWinTimeZonePrivate::QWinTransitio
QDate daylightDate = calculateTransitionLocalDate(rule.daylightTimeRule, year); QDate daylightDate = calculateTransitionLocalDate(rule.daylightTimeRule, year);
QTime daylightTime = QTime(rule.daylightTimeRule.wHour, rule.daylightTimeRule.wMinute, QTime daylightTime = QTime(rule.daylightTimeRule.wHour, rule.daylightTimeRule.wMinute,
rule.daylightTimeRule.wSecond); rule.daylightTimeRule.wSecond);
if (standardDate.isValid() && standardTime.isValid()) if (daylightDate.isValid() && daylightTime.isValid())
*dstMSecs = timeToMSecs(daylightDate, daylightTime) + (rule.standardTimeBias * 60000); *dstMSecs = timeToMSecs(daylightDate, daylightTime) + (rule.standardTimeBias * 60000);
else else
*dstMSecs = QTimeZonePrivate::invalidMSecs(); *dstMSecs = QTimeZonePrivate::invalidMSecs();
@ -488,6 +488,9 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons
do { do {
// Convert the transition rules into msecs for the year we want to try // Convert the transition rules into msecs for the year we want to try
rule = ruleForYear(year); 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); calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
if (stdMSecs < dstMSecs) { if (stdMSecs < dstMSecs) {
first = stdMSecs; first = stdMSecs;
@ -543,6 +546,9 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::nextTransition(qint64 afterMSecsSinc
do { do {
// Convert the transition rules into msecs for the year we want to try // Convert the transition rules into msecs for the year we want to try
rule = ruleForYear(year); 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); calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
// Find the first and second transition for the year // Find the first and second transition for the year
if (stdMSecs < dstMSecs) { if (stdMSecs < dstMSecs) {
@ -591,6 +597,9 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSec
do { do {
// Convert the transition rules into msecs for the year we want to try // Convert the transition rules into msecs for the year we want to try
rule = ruleForYear(year); 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); calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
if (stdMSecs < dstMSecs) { if (stdMSecs < dstMSecs) {
first = stdMSecs; first = stdMSecs;