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
32 /// <since_tizen> 4 </since_tizen>
33 protected bool swigCMemOwn;
36 /// A Flat to check if it is already disposed.
38 /// <since_tizen> 4 </since_tizen>
39 protected bool disposed = false;
41 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
42 //A Flag to check who called Dispose(). (By User or DisposeQueue)
43 private bool isDisposeQueued = false;
48 /// <since_tizen> 4 </since_tizen>
49 public WatchTime() : this(NDalicManualPINVOKE.new_WatchTime(), true)
51 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54 internal WatchTime(global::System.IntPtr cPtr, bool cMemoryOwn)
56 swigCMemOwn = cMemoryOwn;
57 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
67 isDisposeQueued = true;
68 DisposeQueue.Instance.Add(this);
73 /// Get the current hour.
75 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
76 /// <since_tizen> 4 </since_tizen>
86 /// Get the current hour24.
88 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
89 /// <since_tizen> 4 </since_tizen>
99 /// Get the current minute.
101 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
102 /// <since_tizen> 4 </since_tizen>
112 /// Get the current second.
114 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
115 /// <since_tizen> 4 </since_tizen>
125 /// Get the current millisecond.
127 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
128 /// <since_tizen> 4 </since_tizen>
129 public int Millisecond
133 return GetMillisecond();
138 /// Get the current year.
140 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
141 /// <since_tizen> 4 </since_tizen>
151 /// Get the current month.
153 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
154 /// <since_tizen> 4 </since_tizen>
164 /// Get the current day.
166 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
167 /// <since_tizen> 4 </since_tizen>
177 /// Get the current week.
179 /// <remarks>The return value is always positive.The WatchTime needs to be initialized.</remarks>
180 /// <since_tizen> 4 </since_tizen>
185 return GetDayOfWeek();
190 /// Get the ID of timezone.
193 /// The WatchTime needs to be initialized.<br/>
194 /// The timezone ID, according to the IANA(Internet Assigned Numbers Authority)<br/>
195 /// If you want to see more information, please refer to the site :<br/>
196 /// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones/
198 /// <since_tizen> 4 </since_tizen>
199 public string TimeZone
203 return GetTimeZone();
208 /// Get the daylight saving time status.
210 /// <remarks>The WatchTime needs to be initialized.</remarks>
211 /// <since_tizen> 4 </since_tizen>
212 public bool DaylightSavingTimeStatus
216 return GetDaylightSavingTimeStatus();
221 /// To make watch time instance be disposed.
223 /// <since_tizen> 4 </since_tizen>
224 public void Dispose()
226 //Throw excpetion if Dispose() is called in separate thread.
227 if (!Window.IsInstalled())
229 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
234 Dispose(DisposeTypes.Implicit);
238 Dispose(DisposeTypes.Explicit);
239 System.GC.SuppressFinalize(this);
243 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WatchTime obj)
245 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
248 internal static WatchTime GetWatchTimeFromPtr(global::System.IntPtr cPtr)
250 WatchTime ret = new WatchTime(cPtr, false);
251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 internal int GetDayOfWeek()
257 int ret = NDalicManualPINVOKE.WatchTime_GetDayOfWeek(swigCPtr);
258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 internal SWIGTYPE_p_tm GetUtcTime()
264 SWIGTYPE_p_tm ret = new SWIGTYPE_p_tm(NDalicManualPINVOKE.WatchTime_GetUtcTime(swigCPtr), true);
265 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269 internal SWIGTYPE_p_time_t GetUtcTimeStamp()
271 SWIGTYPE_p_time_t ret = new SWIGTYPE_p_time_t(NDalicManualPINVOKE.WatchTime_GetUtcTimeStamp(swigCPtr), true);
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276 internal string GetTimeZone()
278 string ret = NDalicManualPINVOKE.WatchTime_GetTimeZone(swigCPtr);
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283 internal bool GetDaylightSavingTimeStatus()
285 bool ret = NDalicManualPINVOKE.WatchTime_GetDaylightSavingTimeStatus(swigCPtr);
286 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 internal int GetHour()
292 int ret = NDalicManualPINVOKE.WatchTime_GetHour(swigCPtr);
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 internal int GetHour24()
299 int ret = NDalicManualPINVOKE.WatchTime_GetHour24(swigCPtr);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 internal int GetMinute()
306 int ret = NDalicManualPINVOKE.WatchTime_GetMinute(swigCPtr);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 internal int GetSecond()
313 int ret = NDalicManualPINVOKE.WatchTime_GetSecond(swigCPtr);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 internal int GetMillisecond()
320 int ret = NDalicManualPINVOKE.WatchTime_GetMillisecond(swigCPtr);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 internal int GetYear()
327 int ret = NDalicManualPINVOKE.WatchTime_GetYear(swigCPtr);
328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
332 internal int GetMonth()
334 int ret = NDalicManualPINVOKE.WatchTime_GetMonth(swigCPtr);
335 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 internal int GetDay()
341 int ret = NDalicManualPINVOKE.WatchTime_GetDay(swigCPtr);
342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 /// you can override it to clean-up your own resources.
349 /// <param name="type">DisposeTypes</param>
350 /// <since_tizen> 4 </since_tizen>
351 protected virtual void Dispose(DisposeTypes type)
358 if (type == DisposeTypes.Explicit)
361 //Release your own managed resources here.
362 //You should release all of your own disposable objects here.
366 //Release your own unmanaged resources here.
367 //You should not access any managed member here except static instance.
368 //because the execution order of Finalizes is non-deterministic.
370 if (swigCPtr.Handle != global::System.IntPtr.Zero)
375 NDalicManualPINVOKE.delete_WatchTime(swigCPtr);
377 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);