Ejemplo n.º 1
0
        /// <summary>
        /// Indicates whether this date/time is earlier, later or the same as another one.
        /// </summary>
        /// <remarks>
        /// Only date/time values within the same calendar systems can be compared with this method. Attempting to compare
        /// values within different calendars will fail with an <see cref="ArgumentException"/>. Ideally, comparisons
        /// is almost always preferable to continuing.
        /// </remarks>
        /// <param name="other">The other local date/time to compare with this value.</param>
        /// <exception cref="ArgumentException">The calendar system of <paramref name="other"/> is not the
        /// same as the calendar system of this value.</exception>
        /// <returns>A value less than zero if this date/time is earlier than <paramref name="other"/>;
        /// zero if this date/time is the same as <paramref name="other"/>; a value greater than zero if this date/time is
        /// later than <paramref name="other"/>.</returns>
        public int CompareTo(LocalDateTime other)
        {
            // This will check calendars...
            int dateComparison = date.CompareTo(other.date);

            if (dateComparison != 0)
            {
                return(dateComparison);
            }
            return(time.CompareTo(other.time));
        }