From bea4641b0db0060e75f2e9e7f764dcd98c7a59cc Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Fri, 9 Aug 2013 16:32:44 +0000 Subject: [PATCH] ICU-10281 Fixed a VTIMEZONE writer problem that may produce overlapping rules. X-SVN-Rev: 34026 --- icu4c/source/i18n/vtzone.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/icu4c/source/i18n/vtzone.cpp b/icu4c/source/i18n/vtzone.cpp index dba7a29245a..426810ec322 100644 --- a/icu4c/source/i18n/vtzone.cpp +++ b/icu4c/source/i18n/vtzone.cpp @@ -18,6 +18,7 @@ #include "cmemory.h" #include "uvector.h" #include "gregoimp.h" +#include "uassert.h" U_NAMESPACE_BEGIN @@ -2109,8 +2110,13 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, if (U_FAILURE(status)) { goto cleanupWriteZone; } - writeFinalRule(w, TRUE, finalDstRule, - dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, dstStartTime, status); + UDate nextStart; + UBool nextStartAvail = finalDstRule->getNextStart(dstUntilTime, dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, false, nextStart); + U_ASSERT(nextStartAvail); + if (nextStartAvail) { + writeFinalRule(w, TRUE, finalDstRule, + dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, nextStart, status); + } } } if (U_FAILURE(status)) { @@ -2138,7 +2144,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, // Use a single rule if possible if (isEquivalentDateRule(stdMonth, stdWeekInMonth, stdDayOfWeek, finalStdRule->getRule())) { writeZonePropsByDOW(w, FALSE, stdName, stdFromOffset, stdToOffset, - stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, MAX_MILLIS, status); + stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, MAX_MILLIS, status); } else { // Not equivalent rule - write out two different rules writeZonePropsByDOW(w, FALSE, stdName, stdFromOffset, stdToOffset, @@ -2146,8 +2152,13 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, if (U_FAILURE(status)) { goto cleanupWriteZone; } - writeFinalRule(w, FALSE, finalStdRule, - stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, stdStartTime, status); + UDate nextStart; + UBool nextStartAvail = finalStdRule->getNextStart(stdUntilTime, stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, false, nextStart); + U_ASSERT(nextStartAvail); + if (nextStartAvail) { + writeFinalRule(w, FALSE, finalStdRule, + stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, nextStart, status); + } } } if (U_FAILURE(status)) { -- 2.40.0