2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FLcl_TimeZoneImpl.h
20 * @brief This is the header file for the _TimeZoneImpl class.
22 * This header file contains declarations of the _TimeZoneImpl class.
26 #ifndef _FLCL_INTERNAL_TIME_ZONE_IMPL_H_
27 #define _FLCL_INTERNAL_TIME_ZONE_IMPL_H_
29 #include <unicode/simpletz.h>
31 #include <FBaseObject.h>
32 #include <FBaseString.h>
33 #include <FLclTimeRule.h>
34 #include <FLclTimeZone.h>
36 namespace Tizen { namespace Locales
40 : public Tizen::Base::Object
45 _TimeZoneImpl(int rawOffset, const Tizen::Base::String& id);
46 _TimeZoneImpl(int rawOffset, const Tizen::Base::String& id, const TimeRule& startRule, const TimeRule& endRule, int dstOffset);
47 _TimeZoneImpl(U_ICU_NAMESPACE::TimeZone& icuTimeZone);
48 _TimeZoneImpl(U_ICU_NAMESPACE::TimeZone& icuTimeZone, UDate icuDate);
50 _TimeZoneImpl(const _TimeZoneImpl& otherTimeZone);
52 virtual ~_TimeZoneImpl(void);
54 _TimeZoneImpl& operator =(const _TimeZoneImpl& otherTimeZone);
55 _TimeZoneImpl* CloneN(void);
57 bool operator ==(const _TimeZoneImpl& otherTimeZone) const;
58 bool operator !=(const _TimeZoneImpl& otherTimeZone) const;
59 virtual bool Equals(const Tizen::Base::Object& obj) const;
60 virtual int GetHashCode(void) const;
62 Tizen::Base::String GetId(void) const;
63 void SetId(const Tizen::Base::String& id);
65 int GetRawOffset(void) const;
66 void SetRawOffset(int rawOffset);
68 int GetDstStartingYear(void) const;
69 void SetDstStartingYear(int year);
71 int GetDstSavings(void) const;
72 void SetDstSavings(int dstSavings);
74 const TimeRule* GetDstStartingRule(void) const;
75 void SetDstStartingRule(const TimeRule& startRule);
77 const TimeRule* GetDstEndingRule(void) const;
78 void SetDstEndingRule(const TimeRule& endRule);
80 result SetDstRules(const TimeRule& startRule, const TimeRule& endRule, int dstSavings = 60);
82 result GetOffset(const Tizen::Base::DateTime& date, bool local, int& rawOffset, int& dstOffset) const;
83 result GetOffset(long long ticks, int& offset) const;
84 bool IsDstUsed(void) const;
86 U_ICU_NAMESPACE::SimpleTimeZone GetIcuTimeZone(void) const;
88 static const _TimeZoneImpl* GetTimeZoneImpl(const TimeZone& ospTimeZone);
89 static result GetTimeZone(const Tizen::Base::String& id, Tizen::Locales::TimeZone& timeZone);
90 static result GetTimeZone(const Tizen::Base::String& id, const Tizen::Base::DateTime& utcTime, Tizen::Locales::TimeZone& timeZone);
93 void GetIcuTimeRuleValue(const TimeRule& ospRule, int& month, int& dayOfWeekInMonth, int& dayOfWeek, int& time, int& mode);
94 result GetTimeRuleFromIcuDateTimeRule(const U_ICU_NAMESPACE::DateTimeRule* pIcuRule, TimeRule& ospRule);
97 static const int ONE_MIN_IN_MILLISEC = 60 * 1000;
98 static const int ONE_HOUR_IN_MILLISEC = 60 * ONE_MIN_IN_MILLISEC;
99 static const int ONE_DAY_IN_MILLISEC = 24 * ONE_HOUR_IN_MILLISEC;
100 static const int ONE_DAY_IN_MINUTE = 24 * 60;
103 U_ICU_NAMESPACE::SimpleTimeZone __icuTimeZone;
105 int __dstStartingYear;
106 TimeRule __startingRule;
107 TimeRule __endingRule;
109 static const int DAY_UNDEFINED = -1;
113 #endif //_FLCL_INTERNAL_TIME_ZONE_IMPL_H_