/// <summary> /// Dates the difference. /// </summary> /// <param name="otherDate"> /// The other date. /// </param> /// <returns> /// </returns> public TimeSpan DateDifference(IDateObjectModel otherDate) { if (Valid) { return(SingleDate.Subtract(otherDate.SingleDate)); } return(new TimeSpan()); }
/// <summary> /// Dates the difference. /// </summary> /// <param name="otherDate"> /// The other date. /// </param> /// <returns> /// </returns> public TimeSpan DateDifference(IDateObjectModel otherDate) { Contract.Requires(otherDate != null); if (Valid) { return(SingleDate.Subtract(otherDate.SingleDate).Duration()); } return(new TimeSpan()); }
/// <summary> /// Dates the difference decoded. /// </summary> /// <param name="otherDate"> /// The other date. /// </param> /// <returns> /// </returns> public string DateDifferenceDecoded(IDateObjectModel otherDate) { if (Valid) { // Because we start at year 1 for the Gregorian calendar, we must subtract a year here. DateTime zeroTime = new DateTime(1, 1, 1); int years = (zeroTime + DateDifference(otherDate)).Year - 1; // 1, where my other algorithm resulted in 0. return(years + " years"); } return("Unknown"); }
public int CompareTo(IDateObjectModel other) { Contract.Requires(other != null); return(DateTime.Compare(SortDate, other.SortDate)); }