2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <wearable/watch/watch-time.h>
22 #ifdef APPCORE_WATCH_AVAILABLE
23 #include <watch_app.h>
24 #include <watch_app_extension.h>
30 struct WatchTime::Impl
32 Impl(void *time_handle)
33 : mTimeHandle(time_handle)
40 WatchTime::WatchTime(void *time_handle)
42 mImpl = new Impl(time_handle);
45 WatchTime::~WatchTime()
54 #ifdef APPCORE_WATCH_AVAILABLE
56 WatchTime::WatchTime()
58 watch_time_h watch_time = {0,};
60 watch_time_get_current_time(&watch_time);
61 mImpl = new Impl(watch_time);
64 int WatchTime::GetHour() const
68 watch_time_get_hour(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour);
72 int WatchTime::GetHour24() const
76 watch_time_get_hour24(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour24);
80 int WatchTime::GetMinute() const
84 watch_time_get_minute(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &minute);
88 int WatchTime::GetSecond() const
92 watch_time_get_second(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &second);
96 int WatchTime::GetMillisecond() const
100 watch_time_get_millisecond(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &millisecond);
104 int WatchTime::GetYear() const
108 watch_time_get_year(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &year);
112 int WatchTime::GetMonth() const
116 watch_time_get_month(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &month);
120 int WatchTime::GetDay() const
124 watch_time_get_day(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &day);
128 int WatchTime::GetDayOfWeek() const
132 watch_time_get_day_of_week(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &dayOfWeek);
136 struct tm WatchTime::GetUtcTime() const
140 watch_time_get_utc_time(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &UtcTime);
144 time_t WatchTime::GetUtcTimeStamp() const
148 watch_time_get_utc_timestamp(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &UtcTimeStamp);
152 const char* WatchTime::GetTimeZone() const
156 watch_time_get_time_zone(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &timeZone);
160 bool WatchTime::GetDaylightSavingTimeStatus() const
164 watch_time_get_daylight_time_status(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &daylight);
169 WatchTime::WatchTime()
174 int WatchTime::GetHour() const
179 int WatchTime::GetHour24() const
184 int WatchTime::GetMinute() const
189 int WatchTime::GetSecond() const
194 int WatchTime::GetMillisecond() const
199 int WatchTime::GetYear() const
204 int WatchTime::GetMonth() const
209 int WatchTime::GetDay() const
214 int WatchTime::GetDayOfWeek() const
219 struct tm WatchTime::GetUtcTime() const
221 time_t zero = time(0);
222 return *localtime(&zero);
225 time_t WatchTime::GetUtcTimeStamp() const
230 const char* WatchTime::GetTimeZone() const
235 bool WatchTime::GetDaylightSavingTimeStatus() const