dali-adaptor internal folder refactoring
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / tizen-wayland / tizen-wearable / watch-time.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/watch/watch-time.h>
20
21 // EXTERNAL INCLUDES
22 #ifdef APPCORE_WATCH_AVAILABLE
23 #include <watch_app.h>
24 #include <watch_app_extension.h>
25 #endif
26
27 namespace Dali
28 {
29
30 struct WatchTime::Impl
31 {
32   Impl(void *time_handle)
33   : mTimeHandle(time_handle)
34   {
35   }
36
37   void *mTimeHandle;
38 };
39
40 WatchTime::WatchTime(void *time_handle)
41 {
42   mImpl = new Impl(time_handle);
43 }
44
45 WatchTime::~WatchTime()
46 {
47   if( mImpl )
48   {
49     delete mImpl;
50     mImpl = NULL;
51   }
52 }
53
54 #ifdef APPCORE_WATCH_AVAILABLE
55
56 WatchTime::WatchTime()
57 {
58   watch_time_h watch_time = {0,};
59
60   watch_time_get_current_time(&watch_time);
61   mImpl = new Impl(watch_time);
62 }
63
64 int WatchTime::GetHour() const
65 {
66   int hour;
67
68   watch_time_get_hour(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour);
69   return hour;
70 }
71
72 int WatchTime::GetHour24() const
73 {
74   int hour24;
75
76   watch_time_get_hour24(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour24);
77   return hour24;
78 }
79
80 int WatchTime::GetMinute() const
81 {
82   int minute;
83
84   watch_time_get_minute(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &minute);
85   return minute;
86 }
87
88 int WatchTime::GetSecond() const
89 {
90   int second;
91
92   watch_time_get_second(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &second);
93   return second;
94 }
95
96 int WatchTime::GetMillisecond() const
97 {
98   int millisecond;
99
100   watch_time_get_millisecond(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &millisecond);
101   return millisecond;
102 }
103
104 int WatchTime::GetYear() const
105 {
106   int year;
107
108   watch_time_get_year(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &year);
109   return year;
110 }
111
112 int WatchTime::GetMonth() const
113 {
114   int month;
115
116   watch_time_get_month(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &month);
117   return month;
118 }
119
120 int WatchTime::GetDay() const
121 {
122   int day;
123
124   watch_time_get_day(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &day);
125   return day;
126 }
127
128 int WatchTime::GetDayOfWeek() const
129 {
130   int dayOfWeek;
131
132   watch_time_get_day_of_week(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &dayOfWeek);
133   return dayOfWeek;
134 }
135
136 struct tm WatchTime::GetUtcTime() const
137 {
138   struct tm UtcTime;
139
140   watch_time_get_utc_time(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &UtcTime);
141   return UtcTime;
142 }
143
144 time_t WatchTime::GetUtcTimeStamp() const
145 {
146   time_t UtcTimeStamp;
147
148   watch_time_get_utc_timestamp(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &UtcTimeStamp);
149   return UtcTimeStamp;
150 }
151
152 const char* WatchTime::GetTimeZone() const
153 {
154   char* timeZone;
155
156   watch_time_get_time_zone(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &timeZone);
157   return timeZone;
158 }
159
160 bool WatchTime::GetDaylightSavingTimeStatus() const
161 {
162   bool daylight;
163
164   watch_time_get_daylight_time_status(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &daylight);
165   return daylight;
166 }
167
168 #else
169 WatchTime::WatchTime()
170   :mImpl(NULL)
171 {
172 }
173
174 int WatchTime::GetHour() const
175 {
176   return 0;
177 }
178
179 int WatchTime::GetHour24() const
180 {
181   return 0;
182 }
183
184 int WatchTime::GetMinute() const
185 {
186   return 0;
187 }
188
189 int WatchTime::GetSecond() const
190 {
191   return 0;
192 }
193
194 int WatchTime::GetMillisecond() const
195 {
196   return 0;
197 }
198
199 int WatchTime::GetYear() const
200 {
201   return 0;
202 }
203
204 int WatchTime::GetMonth() const
205 {
206   return 0;
207 }
208
209 int WatchTime::GetDay() const
210 {
211   return 0;
212 }
213
214 int WatchTime::GetDayOfWeek() const
215 {
216   return 0;
217 }
218
219 struct tm WatchTime::GetUtcTime() const
220 {
221   time_t zero = time(0);
222   return *localtime(&zero);
223 }
224
225 time_t WatchTime::GetUtcTimeStamp() const
226 {
227   return 0;
228 }
229
230 const char* WatchTime::GetTimeZone() const
231 {
232   return 0;
233 }
234
235 bool WatchTime::GetDaylightSavingTimeStatus() const
236 {
237   return 0;
238 }
239
240 #endif
241
242 } // namespace Dali