7c0f63d8a6dc67886504356d48d16973a60cef5d
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / WatchTime.cs
1 /*
2  * Copyright (c) 2017 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 namespace Tizen.NUI
19 {
20     /// <summary>
21     /// The WatchTime class is used to get time for the WatchApplication.<br/>
22     /// A WatchTime has a time handle from watch application framework.<br/>
23     /// You can get time(hour, minute, second, millisecond) and date(year, month, day)<br/>
24     /// on receiving timeTick signal.
25     /// </summary>
26     /// <since_tizen> 4 </since_tizen>
27     public class WatchTime : global::System.IDisposable
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30
31         /// <summary>
32         /// swigCMemOwn.
33         /// </summary>
34         /// <since_tizen> 4 </since_tizen>
35         protected bool swigCMemOwn;
36
37         internal WatchTime(global::System.IntPtr cPtr, bool cMemoryOwn)
38         {
39             swigCMemOwn = cMemoryOwn;
40             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
41         }
42
43         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WatchTime obj)
44         {
45             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46         }
47
48         //A Flag to check who called Dispose(). (By User or DisposeQueue)
49         private bool isDisposeQueued = false;
50
51         /// <summary>
52         /// A Flat to check if it is already disposed.
53         /// </summary>
54         /// <since_tizen> 4 </since_tizen>
55         protected bool disposed = false;
56
57         /// <summary>
58         /// Distructor.
59         /// </summary>
60         ~WatchTime()
61         {
62             if (!isDisposeQueued)
63             {
64                 isDisposeQueued = true;
65                 DisposeQueue.Instance.Add(this);
66             }
67         }
68
69         /// <summary>
70         /// To make watch time instance be disposed.
71         /// </summary>
72         /// <since_tizen> 4 </since_tizen>
73         public void Dispose()
74         {
75             //Throw excpetion if Dispose() is called in separate thread.
76             if (!Window.IsInstalled())
77             {
78                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
79             }
80
81             if (isDisposeQueued)
82             {
83                 Dispose(DisposeTypes.Implicit);
84             }
85             else
86             {
87                 Dispose(DisposeTypes.Explicit);
88                 System.GC.SuppressFinalize(this);
89             }
90         }
91
92         /// <summary>
93         /// you can override it to clean-up your own resources.
94         /// </summary>
95         /// <param name="type">DisposeTypes</param>
96         /// <since_tizen> 4 </since_tizen>
97         protected virtual void Dispose(DisposeTypes type)
98         {
99             if (disposed)
100             {
101                 return;
102             }
103
104             if (type == DisposeTypes.Explicit)
105             {
106                 //Called by User
107                 //Release your own managed resources here.
108                 //You should release all of your own disposable objects here.
109
110             }
111
112             //Release your own unmanaged resources here.
113             //You should not access any managed member here except static instance.
114             //because the execution order of Finalizes is non-deterministic.
115
116             if (swigCPtr.Handle != global::System.IntPtr.Zero)
117             {
118                 if (swigCMemOwn)
119                 {
120                     swigCMemOwn = false;
121                     NDalicManualPINVOKE.delete_WatchTime(swigCPtr);
122                 }
123                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
124             }
125
126             disposed = true;
127         }
128
129         internal static WatchTime GetWatchTimeFromPtr(global::System.IntPtr cPtr)
130         {
131             WatchTime ret = new WatchTime(cPtr, false);
132             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133             return ret;
134         }
135
136         /// <summary>
137         /// Constructor.
138         /// </summary>
139         /// <since_tizen> 4 </since_tizen>
140         public WatchTime() : this(NDalicManualPINVOKE.new_WatchTime(), true)
141         {
142             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143         }
144
145         /// <summary>
146         /// Get the current hour.
147         /// </summary>
148         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
149         /// <since_tizen> 4 </since_tizen>
150         public int Hour
151         {
152             get
153             {
154                 return GetHour();
155             }
156         }
157
158         internal int GetHour()
159         {
160             int ret = NDalicManualPINVOKE.WatchTime_GetHour(swigCPtr);
161             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162             return ret;
163         }
164
165         /// <summary>
166         /// Get the current hour24.
167         /// </summary>
168         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
169         /// <since_tizen> 4 </since_tizen>
170         public int Hour24
171         {
172             get
173             {
174                 return GetHour24();
175             }
176         }
177
178         internal int GetHour24()
179         {
180             int ret = NDalicManualPINVOKE.WatchTime_GetHour24(swigCPtr);
181             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182             return ret;
183         }
184
185         /// <summary>
186         /// Get the current minute.
187         /// </summary>
188         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
189         /// <since_tizen> 4 </since_tizen>
190         public int Minute
191         {
192             get
193             {
194                 return GetMinute();
195             }
196         }
197
198         internal int GetMinute()
199         {
200             int ret = NDalicManualPINVOKE.WatchTime_GetMinute(swigCPtr);
201             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202             return ret;
203         }
204
205         /// <summary>
206         /// Get the current second.
207         /// </summary>
208         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
209         /// <since_tizen> 4 </since_tizen>
210         public int Second
211         {
212             get
213             {
214                 return GetSecond();
215             }
216         }
217
218         internal int GetSecond()
219         {
220             int ret = NDalicManualPINVOKE.WatchTime_GetSecond(swigCPtr);
221             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222             return ret;
223         }
224
225         /// <summary>
226         /// Get the current millisecond.
227         /// </summary>
228         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
229         /// <since_tizen> 4 </since_tizen>
230         public int Millisecond
231         {
232             get
233             {
234                 return GetMillisecond();
235             }
236         }
237
238         internal int GetMillisecond()
239         {
240             int ret = NDalicManualPINVOKE.WatchTime_GetMillisecond(swigCPtr);
241             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242             return ret;
243         }
244
245         /// <summary>
246         /// Get the current year.
247         /// </summary>
248         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
249         /// <since_tizen> 4 </since_tizen>
250         public int Year
251         {
252             get
253             {
254                 return GetYear();
255             }
256         }
257
258         internal int GetYear()
259         {
260             int ret = NDalicManualPINVOKE.WatchTime_GetYear(swigCPtr);
261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262             return ret;
263         }
264
265         /// <summary>
266         /// Get the current month.
267         /// </summary>
268         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
269         /// <since_tizen> 4 </since_tizen>
270         public int Month
271         {
272             get
273             {
274                 return GetMonth();
275             }
276         }
277
278         internal int GetMonth()
279         {
280             int ret = NDalicManualPINVOKE.WatchTime_GetMonth(swigCPtr);
281             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282             return ret;
283         }
284
285         /// <summary>
286         /// Get the current day.
287         /// </summary>
288         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
289         /// <since_tizen> 4 </since_tizen>
290         public int Day
291         {
292             get
293             {
294                 return GetDay();
295             }
296         }
297
298         internal int GetDay()
299         {
300             int ret = NDalicManualPINVOKE.WatchTime_GetDay(swigCPtr);
301             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302             return ret;
303         }
304
305         /// <summary>
306         /// Get the current week.
307         /// </summary>
308         /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
309         /// <since_tizen> 4 </since_tizen>
310         public int DayOfWeek
311         {
312             get
313             {
314                 return GetDayOfWeek();
315             }
316         }
317
318         internal int GetDayOfWeek()
319         {
320             int ret = NDalicManualPINVOKE.WatchTime_GetDayOfWeek(swigCPtr);
321             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322             return ret;
323         }
324
325         internal SWIGTYPE_p_tm GetUtcTime()
326         {
327             SWIGTYPE_p_tm ret = new SWIGTYPE_p_tm(NDalicManualPINVOKE.WatchTime_GetUtcTime(swigCPtr), true);
328             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329             return ret;
330         }
331
332         internal SWIGTYPE_p_time_t GetUtcTimeStamp()
333         {
334             SWIGTYPE_p_time_t ret = new SWIGTYPE_p_time_t(NDalicManualPINVOKE.WatchTime_GetUtcTimeStamp(swigCPtr), true);
335             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336             return ret;
337         }
338
339         /// <summary>
340         /// Get the ID of timezone.
341         /// </summary>
342         /// <remarks>
343         /// The WatchTime needs to be initialized.<br/>
344         /// The timezone ID, according to the IANA(Internet Assigned Numbers Authority)<br/>
345         /// If you want to see more information, please refer to the site :<br/>
346         /// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones/
347         /// </remarks>
348         /// <since_tizen> 4 </since_tizen>
349         public string TimeZone
350         {
351             get
352             {
353                 return GetTimeZone();
354             }
355         }
356
357         internal string GetTimeZone()
358         {
359             string ret = NDalicManualPINVOKE.WatchTime_GetTimeZone(swigCPtr);
360             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
361             return ret;
362         }
363
364         /// <summary>
365         /// Get the daylight saving time status.
366         /// </summary>
367         /// <remarks>The WatchTime needs to be initialized.</remarks>
368         /// <since_tizen> 4 </since_tizen>
369         public bool DaylightSavingTimeStatus
370         {
371             get
372             {
373                 return GetDaylightSavingTimeStatus();
374             }
375         }
376
377         internal bool GetDaylightSavingTimeStatus()
378         {
379             bool ret = NDalicManualPINVOKE.WatchTime_GetDaylightSavingTimeStatus(swigCPtr);
380             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381             return ret;
382         }
383
384     }
385
386 }