2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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.
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.
26 /// <since_tizen> 4 </since_tizen>
27 public class WatchTime : global::System.IDisposable
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
34 /// <since_tizen> 4 </since_tizen>
35 protected bool swigCMemOwn;
37 internal WatchTime(global::System.IntPtr cPtr, bool cMemoryOwn)
39 swigCMemOwn = cMemoryOwn;
40 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
43 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WatchTime obj)
45 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
48 //A Flag to check who called Dispose(). (By User or DisposeQueue)
49 private bool isDisposeQueued = false;
52 /// A Flat to check if it is already disposed.
54 /// <since_tizen> 4 </since_tizen>
55 protected bool disposed = false;
64 isDisposeQueued = true;
65 DisposeQueue.Instance.Add(this);
70 /// To make watch time instance be disposed.
72 /// <since_tizen> 4 </since_tizen>
75 //Throw excpetion if Dispose() is called in separate thread.
76 if (!Window.IsInstalled())
78 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
83 Dispose(DisposeTypes.Implicit);
87 Dispose(DisposeTypes.Explicit);
88 System.GC.SuppressFinalize(this);
93 /// you can override it to clean-up your own resources.
95 /// <param name="type">DisposeTypes</param>
96 /// <since_tizen> 4 </since_tizen>
97 protected virtual void Dispose(DisposeTypes type)
104 if (type == DisposeTypes.Explicit)
107 //Release your own managed resources here.
108 //You should release all of your own disposable objects here.
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.
116 if (swigCPtr.Handle != global::System.IntPtr.Zero)
121 NDalicManualPINVOKE.delete_WatchTime(swigCPtr);
123 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
129 internal static WatchTime GetWatchTimeFromPtr(global::System.IntPtr cPtr)
131 WatchTime ret = new WatchTime(cPtr, false);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139 /// <since_tizen> 4 </since_tizen>
140 public WatchTime() : this(NDalicManualPINVOKE.new_WatchTime(), true)
142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146 /// Get the current hour.
148 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
149 /// <since_tizen> 4 </since_tizen>
158 internal int GetHour()
160 int ret = NDalicManualPINVOKE.WatchTime_GetHour(swigCPtr);
161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166 /// Get the current hour24.
168 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
169 /// <since_tizen> 4 </since_tizen>
178 internal int GetHour24()
180 int ret = NDalicManualPINVOKE.WatchTime_GetHour24(swigCPtr);
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186 /// Get the current minute.
188 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
189 /// <since_tizen> 4 </since_tizen>
198 internal int GetMinute()
200 int ret = NDalicManualPINVOKE.WatchTime_GetMinute(swigCPtr);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 /// Get the current second.
208 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
209 /// <since_tizen> 4 </since_tizen>
218 internal int GetSecond()
220 int ret = NDalicManualPINVOKE.WatchTime_GetSecond(swigCPtr);
221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226 /// Get the current millisecond.
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
234 return GetMillisecond();
238 internal int GetMillisecond()
240 int ret = NDalicManualPINVOKE.WatchTime_GetMillisecond(swigCPtr);
241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 /// Get the current year.
248 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
249 /// <since_tizen> 4 </since_tizen>
258 internal int GetYear()
260 int ret = NDalicManualPINVOKE.WatchTime_GetYear(swigCPtr);
261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266 /// Get the current month.
268 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
269 /// <since_tizen> 4 </since_tizen>
278 internal int GetMonth()
280 int ret = NDalicManualPINVOKE.WatchTime_GetMonth(swigCPtr);
281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286 /// Get the current day.
288 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
289 /// <since_tizen> 4 </since_tizen>
298 internal int GetDay()
300 int ret = NDalicManualPINVOKE.WatchTime_GetDay(swigCPtr);
301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306 /// Get the current week.
308 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
309 /// <since_tizen> 4 </since_tizen>
314 return GetDayOfWeek();
318 internal int GetDayOfWeek()
320 int ret = NDalicManualPINVOKE.WatchTime_GetDayOfWeek(swigCPtr);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 internal SWIGTYPE_p_tm GetUtcTime()
327 SWIGTYPE_p_tm ret = new SWIGTYPE_p_tm(NDalicManualPINVOKE.WatchTime_GetUtcTime(swigCPtr), true);
328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
332 internal SWIGTYPE_p_time_t GetUtcTimeStamp()
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();
340 /// Get the ID of timezone.
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/
348 /// <since_tizen> 4 </since_tizen>
349 public string TimeZone
353 return GetTimeZone();
357 internal string GetTimeZone()
359 string ret = NDalicManualPINVOKE.WatchTime_GetTimeZone(swigCPtr);
360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365 /// Get the daylight saving time status.
367 /// <remarks>The WatchTime needs to be initialized.</remarks>
368 /// <since_tizen> 4 </since_tizen>
369 public bool DaylightSavingTimeStatus
373 return GetDaylightSavingTimeStatus();
377 internal bool GetDaylightSavingTimeStatus()
379 bool ret = NDalicManualPINVOKE.WatchTime_GetDaylightSavingTimeStatus(swigCPtr);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();