Update change log and spec for wrt-plugins-tizen_0.4.9
[platform/framework/web/wrt-plugins-tizen.git] / src / TimeUtil / TZDate.h
1 //
2 // Tizen Web Device API
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
20
21 #ifndef _TZDATE_H_
22 #define _TZDATE_H_
23
24 #include <string>
25 #include <ctime>
26
27 #include <unicode/calendar.h>
28
29 #include "TZDateProperties.h"
30 #include "DurationProperties.h"
31
32 namespace DeviceAPI {
33 namespace Time {
34         
35 class TZDate
36 {
37         
38         public:
39         enum TZDateFields {
40                 TZDATE_ERA,
41                 TZDATE_YEAR,
42                 TZDATE_MONTH,
43                 TZDATE_WEEK_OF_YEAR,
44                 TZDATE_WEEK_OF_MONTH,
45                 TZDATE_DATE,
46                 TZDATE_DAY_OF_YEAR,
47                 TZDATE_DAY_OF_WEEK,
48                 TZDATE_DAY_OF_WEEK_IN_MONTH,
49                 TZDATE_AM_PM,
50                 TZDATE_HOUR,
51                 TZDATE_HOUR_OF_DAY,
52                 TZDATE_MINUTE,
53                 TZDATE_SECOND,
54                 TZDATE_MILLISECOND,
55                 TZDATE_ZONE_OFFSET,
56                 TZDATE_DST_OFFSET,
57
58                 TZDATE_FIELDS_COUNT,
59         };
60         
61         enum DSTTransition {
62                 PREV_TRANSITION,
63                 NEXT_TRANSITION
64         };
65
66                 TZDate(const bool isNotNull = TRUE);
67                 TZDate(const std::string &timezone);
68                 TZDate(const TZDateProperties &properties); 
69                 virtual      ~TZDate();
70
71                 virtual bool  isNull();
72                 virtual long get(const TZDateFields field);
73                 virtual std::string getTimezone();
74                 virtual TZDateProperties toTimezone(const std::string timezone);
75                 virtual void set(const TZDateFields field, const long value);
76
77                 virtual long getUTC(const TZDateFields field);
78                 virtual void setUTC(const TZDateFields field, const long value);
79
80                 virtual long long difference(const TZDateProperties &prop);
81                 virtual TZDateProperties addDuration(const DurationProperties &duration);
82                 virtual std::string getUTCTimezoneName();
83                 virtual std::string getLocalTimezoneName();
84                 virtual TZDateProperties makeProperties();
85
86                 virtual double getTime();
87                 virtual bool setTime(const double time);
88                 virtual std::string toDateString(bool bLocale = false) ;
89                 virtual std::string toTimeString(bool bLocale = false);
90                 virtual std::string toString(bool bLocale = false);
91
92                 virtual std::string getTimezoneAbbreviation();
93                 virtual long secondsFromUTC();          
94                 virtual bool isDST();
95                 virtual TZDateProperties getDSTTransition(DSTTransition trans);
96
97         private:
98                 long _get(const TZDateFields field, icu::Calendar *cal);
99                 std::string _getTimezoneName(icu::Calendar *cal);
100                 const UCalendarDateFields _convertDateField(const TZDateFields field);
101
102                 icu::Calendar * _makeCalendar(const TZDateProperties &properties);
103                 TZDateProperties _makeProperties(icu::Calendar *cal);
104
105                 icu::Calendar *myCalendar;
106          
107 };
108
109 typedef DPL::SharedPtr<TZDate> TZDatePtr;
110
111 }
112 }
113
114 #endif /* _DATETIME_H_ */