Apply historical dst offset for timezone.
authorHokwon Song <hokwon.song@samsung.com>
Tue, 27 Aug 2013 10:07:08 +0000 (19:07 +0900)
committerHokwon Song <hokwon.song@samsung.com>
Tue, 27 Aug 2013 10:10:57 +0000 (19:10 +0900)
Change-Id: Ifeca121b396f9658012793a604ed11f89e38347c
Signed-off-by: Hokwon Song <hokwon.song@samsung.com>
src/locales/FLcl_TimeZoneImpl.cpp
src/locales/FLcl_TimeZoneImpl.h

index 9d6873a..e4b3c45 100644 (file)
@@ -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<U_ICU_NAMESPACE::BasicTimeZone*>(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;
 }
 
index ed5c7f8..4baafbc 100644 (file)
@@ -101,6 +101,7 @@ public:
 private:
        U_ICU_NAMESPACE::TimeZone* __pIcuTimeZone;
 
+       int __dstSaving;
        int __dstStartingYear;
        TimeRule __startingRule;
        TimeRule __endingRule;