From 6c5017c9ff661e1af20eeee606442ee2bdff4488 Mon Sep 17 00:00:00 2001 From: Hokwon Song Date: Tue, 27 Aug 2013 19:07:08 +0900 Subject: [PATCH] Apply historical dst offset for timezone. Change-Id: Ifeca121b396f9658012793a604ed11f89e38347c Signed-off-by: Hokwon Song --- src/locales/FLcl_TimeZoneImpl.cpp | 17 ++++++++++++++--- src/locales/FLcl_TimeZoneImpl.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/locales/FLcl_TimeZoneImpl.cpp b/src/locales/FLcl_TimeZoneImpl.cpp index 9d6873a..e4b3c45 100644 --- a/src/locales/FLcl_TimeZoneImpl.cpp +++ b/src/locales/FLcl_TimeZoneImpl.cpp @@ -54,6 +54,7 @@ namespace Tizen { namespace Locales _TimeZoneImpl::_TimeZoneImpl(void) : __pIcuTimeZone(null) + , __dstSaving(60) , __dstStartingYear(0) , __startingRule(MONTH_UNDEFINED, DAY_UNDEFINED) , __endingRule(MONTH_UNDEFINED, DAY_UNDEFINED) @@ -65,6 +66,7 @@ _TimeZoneImpl::_TimeZoneImpl(void) _TimeZoneImpl::_TimeZoneImpl(int rawOffset, const String& id) : __pIcuTimeZone(null) + , __dstSaving(60) , __dstStartingYear(0) , __startingRule(MONTH_UNDEFINED, DAY_UNDEFINED) , __endingRule(MONTH_UNDEFINED, DAY_UNDEFINED) @@ -77,6 +79,7 @@ _TimeZoneImpl::_TimeZoneImpl(int rawOffset, const String& id) _TimeZoneImpl::_TimeZoneImpl(int rawOffset, const String& id, const TimeRule& startRule, const TimeRule& endRule, int dstOffset) : __pIcuTimeZone(null) + , __dstSaving(dstOffset) , __dstStartingYear(0) , __startingRule(MONTH_UNDEFINED, DAY_UNDEFINED) , __endingRule(MONTH_UNDEFINED, DAY_UNDEFINED) @@ -90,6 +93,7 @@ _TimeZoneImpl::_TimeZoneImpl(int rawOffset, const String& id, const TimeRule& st _TimeZoneImpl::_TimeZoneImpl(const _TimeZoneImpl& otherTimeZone) : __pIcuTimeZone(null) + , __dstSaving(otherTimeZone.__dstSaving) , __dstStartingYear(otherTimeZone.__dstStartingYear) , __startingRule(otherTimeZone.__startingRule) , __endingRule(otherTimeZone.__endingRule) @@ -101,6 +105,7 @@ _TimeZoneImpl::_TimeZoneImpl(const _TimeZoneImpl& otherTimeZone) _TimeZoneImpl::_TimeZoneImpl(U_ICU_NAMESPACE::TimeZone* pIcuTimeZone) : __pIcuTimeZone(null) + , __dstSaving(60) , __dstStartingYear(0) , __startingRule(MONTH_UNDEFINED, DAY_UNDEFINED) , __endingRule(MONTH_UNDEFINED, DAY_UNDEFINED) @@ -111,13 +116,13 @@ _TimeZoneImpl::_TimeZoneImpl(U_ICU_NAMESPACE::TimeZone* pIcuTimeZone) _TimeZoneImpl::_TimeZoneImpl(U_ICU_NAMESPACE::TimeZone* pIcuTimeZone, UDate icuDate) : __pIcuTimeZone(null) + , __dstSaving(60) , __dstStartingYear(0) , __startingRule(MONTH_UNDEFINED, DAY_UNDEFINED) , __endingRule(MONTH_UNDEFINED, DAY_UNDEFINED) , __isCustomizing(false) { __pIcuTimeZone = pIcuTimeZone; - U_ICU_NAMESPACE::BasicTimeZone* pIcuTz = dynamic_cast(pIcuTimeZone); if (pIcuTz) { @@ -134,9 +139,9 @@ _TimeZoneImpl::_TimeZoneImpl(U_ICU_NAMESPACE::TimeZone* pIcuTimeZone, UDate icuD { GetTimeRuleFromIcuDateTimeRule(pStd->getRule(), __endingRule); __dstStartingYear = pDst->getStartYear(); + __dstSaving = pIcuTz->getDSTSavings() / ONE_MIN_IN_MILLISEC; } } - delete pInitial; delete pStd; delete pDst; @@ -155,6 +160,7 @@ _TimeZoneImpl::operator =(const _TimeZoneImpl& otherTimeZone) if (*this != otherTimeZone) { __pIcuTimeZone = otherTimeZone.__pIcuTimeZone; + __dstSaving = otherTimeZone.__dstSaving; __dstStartingYear = otherTimeZone.__dstStartingYear; __startingRule = otherTimeZone.__startingRule; __endingRule = otherTimeZone.__endingRule; @@ -270,7 +276,11 @@ _TimeZoneImpl::SetDstStartingYear(int year) int _TimeZoneImpl::GetDstSavings(void) const { - return __pIcuTimeZone->getDSTSavings() / ONE_MIN_IN_MILLISEC; + if (__isCustomizing) + { + return __pIcuTimeZone->getDSTSavings() / ONE_MIN_IN_MILLISEC; + } + return __dstSaving; } void @@ -290,6 +300,7 @@ _TimeZoneImpl::SetDstSavings(int dstSavings) __pIcuTimeZone = pStz; } pStz->setDSTSavings(dstSavings * ONE_MIN_IN_MILLISEC, ec); + __dstSaving = dstSavings; __isCustomizing = true; } diff --git a/src/locales/FLcl_TimeZoneImpl.h b/src/locales/FLcl_TimeZoneImpl.h index ed5c7f8..4baafbc 100644 --- a/src/locales/FLcl_TimeZoneImpl.h +++ b/src/locales/FLcl_TimeZoneImpl.h @@ -101,6 +101,7 @@ public: private: U_ICU_NAMESPACE::TimeZone* __pIcuTimeZone; + int __dstSaving; int __dstStartingYear; TimeRule __startingRule; TimeRule __endingRule; -- 2.7.4