Ejemplo n.º 1
0
        public static bool Overlaps(this DateInterval first, DateInterval second)
        {
            if (first is null)
            {
                throw new ArgumentNullException(nameof(first));
            }
            if (second is null)
            {
                throw new ArgumentNullException(nameof(second));
            }

            return(first.Contains(second.Start) || first.Contains(second.End) ||
                   second.Contains(first.Start) || second.Contains(first.End));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the intersection between the given interval and this interval.
 /// </summary>
 /// <param name="interval">
 /// The specified interval to intersect with this one.
 /// </param>
 /// <returns>
 /// A <see cref="DateInterval"/> corresponding to the intersection between the given interval and the current
 /// instance. If there is no intersection, a null reference is returned.
 /// </returns>
 /// <exception cref="ArgumentException"><paramref name="interval" /> uses a different
 /// calendar to this date interval.</exception>
 public DateInterval?Intersection(DateInterval interval) =>
 Contains(interval) ? interval
         : interval.Contains(this) ? this
         : interval.Contains(Start) ? new DateInterval(Start, interval.End)
         : interval.Contains(End) ? new DateInterval(interval.Start, End)
         : null;