2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 namespace Tizen.Applications
22 /// The information of Watch Time
24 public class WatchTime
26 private readonly SafeWatchTimeHandle _handle;
27 private static readonly string LOGTAG = "Tizen.Applications.WatchApplication";
29 internal WatchTime(SafeWatchTimeHandle handle)
35 /// The information of year
42 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetYear(_handle, out year);
44 if (err != Interop.Watch.ErrorCode.None)
46 Log.Error(LOGTAG, "Failed to get Year err : " + err);
53 /// The information fo month
60 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMonth(_handle, out month);
62 if (err != Interop.Watch.ErrorCode.None)
64 Log.Error(LOGTAG, "Failed to get Month err : " + err);
71 /// The information of day
78 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetDay(_handle, out day);
80 if (err != Interop.Watch.ErrorCode.None)
82 Log.Error(LOGTAG, "Failed to get Day err : " + err);
89 /// The information of day of week
96 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetDayOfWeek(_handle, out dayOfWeek);
98 if (err != Interop.Watch.ErrorCode.None)
100 Log.Error(LOGTAG, "Failed to get Second err : " + err);
107 /// The information of hour
114 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetHour(_handle, out hour);
116 if (err != Interop.Watch.ErrorCode.None)
118 Log.Error(LOGTAG, "Failed to get Hour err : " + err);
125 /// The information of hour for 24 hour form
132 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetHour24(_handle, out hour24);
134 if (err != Interop.Watch.ErrorCode.None)
136 Log.Error(LOGTAG, "Failed to get Hour24 err : " + err);
143 /// The information of Minute
150 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMinute(_handle, out minute);
152 if (err != Interop.Watch.ErrorCode.None)
154 Log.Error(LOGTAG, "Failed to get Minute err : " + err);
161 /// The information of second
168 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetSecond(_handle, out second);
170 if (err != Interop.Watch.ErrorCode.None)
172 Log.Error(LOGTAG, "Failed to get Second err : " + err);
179 /// The information of millisecond
181 public int Millisecond
186 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMillisecond(_handle, out ms);
188 if (err != Interop.Watch.ErrorCode.None)
190 Log.Error(LOGTAG, "Failed to get Second err : " + err);
197 /// The information of timezone
199 public string TimeZone
204 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetTimeZone(_handle, out zone);
206 if (err != Interop.Watch.ErrorCode.None)
208 Log.Error(LOGTAG, "Failed to get Second err : " + err);
215 /// The information of UTC time stamp
217 public DateTime UtcTimestamp
223 Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetUtcTimestamp(_handle, out ts);
225 if (err != Interop.Watch.ErrorCode.None)
227 Log.Error(LOGTAG, "Failed to get UtcTimestamp err : " + err);
230 return (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(ts).ToLocalTime();