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