sync with master
[platform/framework/native/appfw.git] / src / locales / FLcl_TimeZoneImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        FLcl_TimeZoneImpl.h
20  * @brief       This is the header file for the _TimeZoneImpl class.
21  *
22  * This header file contains declarations of the _TimeZoneImpl class.
23  *
24  */
25
26 #ifndef _FLCL_INTERNAL_TIME_ZONE_IMPL_H_
27 #define _FLCL_INTERNAL_TIME_ZONE_IMPL_H_
28
29 #include <unicode/simpletz.h>
30
31 #include <FBaseObject.h>
32 #include <FBaseString.h>
33 #include <FLclTimeRule.h>
34 #include <FLclTimeZone.h>
35
36 namespace Tizen { namespace Locales
37 {
38
39 class _TimeZoneImpl
40         : public Tizen::Base::Object
41 {
42 public:
43
44         _TimeZoneImpl(void);
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);
49
50         _TimeZoneImpl(const _TimeZoneImpl& otherTimeZone);
51
52         virtual ~_TimeZoneImpl(void);
53
54         _TimeZoneImpl& operator =(const _TimeZoneImpl& otherTimeZone);
55         _TimeZoneImpl* CloneN(void);
56
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;
61
62         Tizen::Base::String GetId(void) const;
63         void SetId(const Tizen::Base::String& id);
64
65         int GetRawOffset(void) const;
66         void SetRawOffset(int rawOffset);
67
68         int GetDstStartingYear(void) const;
69         void SetDstStartingYear(int year);
70
71         int GetDstSavings(void) const;
72         void SetDstSavings(int dstSavings);
73
74         const TimeRule* GetDstStartingRule(void) const;
75         void SetDstStartingRule(const TimeRule& startRule);
76
77         const TimeRule* GetDstEndingRule(void) const;
78         void SetDstEndingRule(const TimeRule& endRule);
79
80         result SetDstRules(const TimeRule& startRule, const TimeRule& endRule, int dstSavings = 60);
81
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;
85
86         U_ICU_NAMESPACE::SimpleTimeZone GetIcuTimeZone(void) const;
87
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);
91
92 private:
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);
95
96 public:
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;
101
102 private:
103         U_ICU_NAMESPACE::SimpleTimeZone __icuTimeZone;
104
105         int __dstStartingYear;
106         TimeRule __startingRule;
107         TimeRule __endingRule;
108
109         static const int DAY_UNDEFINED = -1;
110 }; // _TimeZoneImpl
111
112 }} // Tizen::Locales
113 #endif //_FLCL_INTERNAL_TIME_ZONE_IMPL_H_
114