示例#1
0
 /// <summary>
 /// Compares this object to another <see cref="SmartDate"/>
 /// for equality.
 /// </summary>
 public override bool Equals(object obj)
 {
     if (obj is SmartDate)
     {
         SmartDate tmp = (SmartDate)obj;
         if (IsEmpty && tmp.IsEmpty)
         {
             return(true);
         }
         else
         {
             return(Date.Equals(tmp.Date));
         }
     }
     else if (obj is DateTime)
     {
         return(Date.Equals((DateTime)obj));
     }
     else if (obj is string)
     {
         return(CompareTo(obj.ToString()) == 0);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
 /// <summary>
 /// Compares one SmartDate to another.
 /// </summary>
 /// <remarks>
 /// This method works the same as the <see cref="DateTime.CompareTo"/> method
 /// on the Date datetype, with the exception that it
 /// understands the concept of empty date values.
 /// </remarks>
 /// <param name="Value">The date to which we are being compared.</param>
 /// <returns>A value indicating if the comparison date is less than, equal to or greater than this date.</returns>
 public int CompareTo(SmartDate value)
 {
     if (IsEmpty && value.IsEmpty)
     {
         return(0);
     }
     else
     {
         return(_date.CompareTo(value.Date));
     }
 }