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 public class WatchTime : global::System.IDisposable
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33 protected bool swigCMemOwn;
35 internal WatchTime(global::System.IntPtr cPtr, bool cMemoryOwn)
37 swigCMemOwn = cMemoryOwn;
38 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
41 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WatchTime obj)
43 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46 //A Flag to check who called Dispose(). (By User or DisposeQueue)
47 private bool isDisposeQueued = false;
50 /// A Flat to check if it is already disposed.
52 protected bool disposed = false;
61 isDisposeQueued = true;
62 DisposeQueue.Instance.Add(this);
67 /// To make watch time instance be disposed.
71 //Throw excpetion if Dispose() is called in separate thread.
72 if (!Window.IsInstalled())
74 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
79 Dispose(DisposeTypes.Implicit);
83 Dispose(DisposeTypes.Explicit);
84 System.GC.SuppressFinalize(this);
89 /// you can override it to clean-up your own resources.
91 /// <param name="type">DisposeTypes</param>
92 /// <since_tizen> 3 </since_tizen>
93 protected virtual void Dispose(DisposeTypes type)
100 if (type == DisposeTypes.Explicit)
103 //Release your own managed resources here.
104 //You should release all of your own disposable objects here.
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.
112 if (swigCPtr.Handle != global::System.IntPtr.Zero)
117 NDalicManualPINVOKE.delete_WatchTime(swigCPtr);
119 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
125 internal static WatchTime GetWatchTimeFromPtr(global::System.IntPtr cPtr)
127 WatchTime ret = new WatchTime(cPtr, false);
128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 public WatchTime() : this(NDalicManualPINVOKE.new_WatchTime(), true)
137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141 /// Get the current hour.
143 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
152 internal int GetHour()
154 int ret = NDalicManualPINVOKE.WatchTime_GetHour(swigCPtr);
155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 /// Get the current hour24.
162 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
171 internal int GetHour24()
173 int ret = NDalicManualPINVOKE.WatchTime_GetHour24(swigCPtr);
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 /// Get the current minute.
181 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
190 internal int GetMinute()
192 int ret = NDalicManualPINVOKE.WatchTime_GetMinute(swigCPtr);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 /// Get the current second.
200 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
209 internal int GetSecond()
211 int ret = NDalicManualPINVOKE.WatchTime_GetSecond(swigCPtr);
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 /// Get the current millisecond.
219 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
220 public int Millisecond
224 return GetMillisecond();
228 internal int GetMillisecond()
230 int ret = NDalicManualPINVOKE.WatchTime_GetMillisecond(swigCPtr);
231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236 /// Get the current year.
238 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
247 internal int GetYear()
249 int ret = NDalicManualPINVOKE.WatchTime_GetYear(swigCPtr);
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 /// Get the current month.
257 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
266 internal int GetMonth()
268 int ret = NDalicManualPINVOKE.WatchTime_GetMonth(swigCPtr);
269 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 /// Get the current day.
276 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
285 internal int GetDay()
287 int ret = NDalicManualPINVOKE.WatchTime_GetDay(swigCPtr);
288 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293 /// Get the current week.
295 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
300 return GetDayOfWeek();
304 internal int GetDayOfWeek()
306 int ret = NDalicManualPINVOKE.WatchTime_GetDayOfWeek(swigCPtr);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 internal SWIGTYPE_p_tm GetUtcTime()
313 SWIGTYPE_p_tm ret = new SWIGTYPE_p_tm(NDalicManualPINVOKE.WatchTime_GetUtcTime(swigCPtr), true);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 internal SWIGTYPE_p_time_t GetUtcTimeStamp()
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();
326 /// Get the ID of timezone.
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/
334 public string TimeZone
338 return GetTimeZone();
342 internal string GetTimeZone()
344 string ret = NDalicManualPINVOKE.WatchTime_GetTimeZone(swigCPtr);
345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 /// Get the daylight saving time status.
352 /// <remarks>The WatchTime needs to be initialized.</remarks>
353 public bool DaylightSavingTimeStatus
357 return GetDaylightSavingTimeStatus();
361 internal bool GetDaylightSavingTimeStatus()
363 bool ret = NDalicManualPINVOKE.WatchTime_GetDaylightSavingTimeStatus(swigCPtr);
364 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();