/// <summary>
/// A class for time to set, get or calculate.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
public class CalendarTime:IComparable<CalendarTime>
{
internal int _type;
/// <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
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <value>The Utc time</value>
public DateTime UtcTime
{
/// <summary>
/// Get localTime
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <value>The Localtime</value>
public DateTime LocalTime
{
/// <summary>
/// Compare CalendarTime
/// </summary>
+ /// <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 other)
{
if (_type != other._type)
/// <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>
- /// <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 override bool Equals(object obj)
{
var other = obj as CalendarTime;
if (_type != other._type)
{
Log.Error(Globals.LogTag, "Not to compare with different type");
- throw CalendarErrorFactory.GetException((int)CalendarError.InvalidParameter);
+ return false;
}
if (_type == (int)Type.Utc)
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();
+ }
}
}