-
Notifications
You must be signed in to change notification settings - Fork 241
/
WatchTime.cs
executable file
·311 lines (286 loc) · 11.9 KB
/
WatchTime.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
namespace Tizen.Applications
{
/// <summary>
/// The information of the Watch Time.
/// </summary>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public class WatchTime
{
private readonly SafeWatchTimeHandle _handle;
private static readonly string LOGTAG = "Tizen.Applications.WatchApplication";
internal WatchTime(SafeWatchTimeHandle handle)
{
_handle = handle;
}
/// <summary>
/// The information of a year.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int Year
{
get
{
int year;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetYear(_handle, out year);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get Year. err : " + err);
else
Log.Error(LOGTAG, "Failed to get Year err : " + err);
}
return year;
}
}
/// <summary>
/// The information of a month.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int Month
{
get
{
int month;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMonth(_handle, out month);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get Month. err : " + err);
else
Log.Error(LOGTAG, "Failed to get Month err : " + err);
}
return month;
}
}
/// <summary>
/// The information of a day.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int Day
{
get
{
int day;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetDay(_handle, out day);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get Day. err : " + err);
else
Log.Error(LOGTAG, "Failed to get Day err : " + err);
}
return day;
}
}
/// <summary>
/// The information of a day of the week.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int DayOfWeek
{
get
{
int dayOfWeek;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetDayOfWeek(_handle, out dayOfWeek);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get DayOfWeek. err : " + err);
else
Log.Error(LOGTAG, "Failed to get DayOfWeek err : " + err);
}
return dayOfWeek;
}
}
/// <summary>
/// The information of an hour.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int Hour
{
get
{
int hour;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetHour(_handle, out hour);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get Hour. err : " + err);
else
Log.Error(LOGTAG, "Failed to get Hour err : " + err);
}
return hour;
}
}
/// <summary>
/// The information of an hour for the 24 hour format.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int Hour24
{
get
{
int hour24;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetHour24(_handle, out hour24);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get Hour24. err : " + err);
else
Log.Error(LOGTAG, "Failed to get Hour24 err : " + err);
}
return hour24;
}
}
/// <summary>
/// The information of a minute.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int Minute
{
get
{
int minute;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMinute(_handle, out minute);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get Minute. err : " + err);
else
Log.Error(LOGTAG, "Failed to get Minute err : " + err);
}
return minute;
}
}
/// <summary>
/// The information of a second.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int Second
{
get
{
int second;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetSecond(_handle, out second);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get Second. err : " + err);
else
Log.Error(LOGTAG, "Failed to get Second err : " + err);
}
return second;
}
}
/// <summary>
/// The information of a millisecond.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public int Millisecond
{
get
{
int ms;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMillisecond(_handle, out ms);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get Millisecond. err : " + err);
else
Log.Error(LOGTAG, "Failed to get Millisecond err : " + err);
}
return ms;
}
}
/// <summary>
/// The information of the timezone.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public string TimeZone
{
get
{
string zone;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetTimeZone(_handle, out zone);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get TimeZone. err : " + err);
else
Log.Error(LOGTAG, "Failed to get TimeZone err : " + err);
}
return zone;
}
}
/// <summary>
/// The information of the UTC time stamp.
/// </summary>
/// <feature>http://tizen.org/feature/watch_app</feature>
/// <exception cref="NotSupportedException">Thrown when the property is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
[Obsolete("Deprecated since API10. Will be removed in API12.")]
public DateTime UtcTimestamp
{
get
{
long ts = 0;
Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetUtcTimestamp(_handle, out ts);
if (err != Interop.Watch.ErrorCode.None)
{
if (err == Interop.Watch.ErrorCode.NotSupported)
throw new NotSupportedException("Failed to get UtcTimestamp. err : " + err);
else
Log.Error(LOGTAG, "Failed to get UtcTimestamp err : " + err);
}
return (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(ts).AddMilliseconds(Millisecond);
}
}
}
}