*/
using System;
-using System.Runtime.InteropServices;
namespace Tizen.Pims.Calendar
{
/// <summary>
- /// A class for time to set, get or calcurate.
+ /// A class for time to set, get or calculate.
/// </summary>
- public class CalendarTime : IComparable<CalendarTime>
+ /// <since_tizen> 4 </since_tizen>
+ public class CalendarTime:IComparable<CalendarTime>
{
internal int _type;
internal const int milliseconds = 10000000;
/// <summary>
/// Enumeration for the time type.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
public enum Type
{
/// <summary>
/// UTC time
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
Utc,
/// <summary>
/// Local time
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
Local
}
/// <summary>
/// Create UTC CalendarTime
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="utcTime">UTC epoch time. 0 is 1971/01/01</param>
public CalendarTime(long utcTime)
{
/// <summary>
/// Create Local CalendarTime
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="year">year</param>
/// <param name="month">month</param>
/// <param name="day">day</param>
/// <param name="hour">hour</param>
/// <param name="minute">minute</param>
/// <param name="second">second</param>
- /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
- /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
public CalendarTime(int year, int month, int day, int hour, int minute, int second)
{
_type = (int)Type.Local;
}
/// <summary>
- /// Get utcTime
+ /// Get UtcTime
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
+ /// <value>The Utc time</value>
public DateTime UtcTime
{
get;
/// <summary>
/// Get localTime
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
+ /// <value>The Localtime</value>
public DateTime LocalTime
{
get;
/// <summary>
/// Compare CalendarTime
/// </summary>
- /// <param name="t">The CalendarTime to be compared</param>
+ /// <since_tizen> 4 </since_tizen>
+ /// <param name="other">The CalendarTime to be compared</param>
/// <returns>
/// A 32-bit signed integer that indicates the relative order of the objects being compared.
/// </returns>
- /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
- /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
- public int CompareTo(CalendarTime t)
+ public int CompareTo(CalendarTime other)
{
- if (_type != t._type)
+ if (_type != other._type)
{
Log.Error(Globals.LogTag, "Not to compare with different type");
throw CalendarErrorFactory.GetException((int)CalendarError.InvalidParameter);
}
if (_type == (int)Type.Utc)
- return UtcTime.CompareTo(t.UtcTime);
+ return UtcTime.CompareTo(other.UtcTime);
else
- return LocalTime.CompareTo(t.LocalTime);
+ return LocalTime.CompareTo(other.LocalTime);
+ }
+
+ /// <summary>
+ /// Equals CalendarTime
+ /// </summary>
+ /// <since_tizen> 4 </since_tizen>
+ /// <param name="obj">The CalendarTime to be compared</param>
+ /// <returns>
+ /// A 32-bit signed integer that indicates the relative order of the objects being compared.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ var other = obj as CalendarTime;
+ if (_type != other._type)
+ {
+ Log.Error(Globals.LogTag, "Not to compare with different type");
+ return false;
+ }
+
+ if (_type == (int)Type.Utc)
+ return UtcTime.Equals(other.UtcTime);
+ else
+ return LocalTime.Equals(other.LocalTime);
+ }
+
+ /// <summary>
+ /// GetHashCode CalendarTime
+ /// </summary>
+ /// <since_tizen> 4 </since_tizen>
+ /// <returns>
+ /// A hash code for the current object.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ if (_type == (int)Type.Utc)
+ return this.UtcTime.GetHashCode();
+ else
+ return this.LocalTime.GetHashCode();
}
}
}