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