示例#1
0
        /// <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());
        }
示例#2
0
        /// <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());
        }
示例#3
0
        /// <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");
        }
示例#4
0
        public int CompareTo(IDateObjectModel other)
        {
            Contract.Requires(other != null);

            return(DateTime.Compare(SortDate, other.SortDate));
        }