From 537711b4ed7f0a22d4feb6a0085d03ec1ae5fcc1 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 10 Feb 2006 03:08:14 +0000 Subject: [PATCH] ICU-5015 fix offset calculation for historical zones. X-SVN-Rev: 19133 --- icu4c/source/i18n/olsontz.cpp | 71 +++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/icu4c/source/i18n/olsontz.cpp b/icu4c/source/i18n/olsontz.cpp index ccddacb9314..43adcb16bbc 100644 --- a/icu4c/source/i18n/olsontz.cpp +++ b/icu4c/source/i18n/olsontz.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2003-2005, International Business Machines +* Copyright (c) 2003-2006, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Author: Alan Liu @@ -133,10 +133,18 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top, if(U_SUCCESS(ec)) { int32_t jj; for(jj=0;jj= * transition(i), where transition(i) is either the GMT or the local @@ -406,6 +426,10 @@ int32_t OlsonTimeZone::getRawOffset() const { */ int16_t OlsonTimeZone::findTransition(double time, UBool local) const { int16_t i = 0; + U_DEBUG_TZ_MSG(("findTransition(%.1f, %s)\n", time, local?"T":"F")); +#if defined U_DEBUG_TZ + printTime(time*1000.0); +#endif if (transitionCount != 0) { // Linear search from the end is the fastest approach, since @@ -413,10 +437,41 @@ int16_t OlsonTimeZone::findTransition(double time, UBool local) const { for (i = transitionCount - 1; i > 0; --i) { int32_t transition = transitionTimes[i]; if (local) { - transition += zoneOffset(typeData[i]); + int32_t zoneOffsetPrev = zoneOffset(typeData[i-1]); + int32_t zoneOffsetCurr = zoneOffset(typeData[i]); + + // use the lowest offset ( == standard time ). as per tzregts.cpp which says: + + /** + * @bug 4084933 + * The expected behavior of TimeZone around the boundaries is: + * (Assume transition time of 2:00 AM) + * day of onset 1:59 AM STD = display name 1:59 AM ST + * 2:00 AM STD = display name 3:00 AM DT + * day of end 0:59 AM STD = display name 1:59 AM DT + * 1:00 AM STD = display name 1:00 AM ST + */ + if(zoneOffsetPrev= transition) { + U_DEBUG_TZ_MSG(("Found@%d: time=%.1f, localtransition=%d (orig %d) dz %d\n", i, time, transition, transitionTimes[i], + zoneOffset(typeData[i-1]))); +#if defined U_DEBUG_TZ + printTime(transition*1000.0); + printTime(transitionTimes[i]*1000.0); +#endif break; + } else { + U_DEBUG_TZ_MSG(("miss@%d: time=%.1f, localtransition=%d (orig %d) dz %d\n", i, time, transition, transitionTimes[i], + zoneOffset(typeData[i-1]))); +#if defined U_DEBUG_TZ + printTime(transition*1000.0); + printTime(transitionTimes[i]*1000.0); +#endif } } @@ -427,11 +482,13 @@ int16_t OlsonTimeZone::findTransition(double time, UBool local) const { U_ASSERT(local || time < transitionTimes[0] || time >= transitionTimes[i]); U_ASSERT(local || i == transitionCount-1 || time < transitionTimes[i+1]); + U_DEBUG_TZ_MSG(("findTransition(%.1f, %s)= trans %d\n", time, local?"T":"F", i)); i = typeData[i]; } U_ASSERT(i>=0 && i