intersection method
Returns the intersection between the given interval and this interval.
interval
: The specified interval to intersect with this one.
A DateInterval corresponding to the intersection between the given interval and the current instance. If there is no intersection, a null reference is returned.
ArgumentException
:interval
uses a different calendar to this date interval.
Implementation
DateInterval? intersection(DateInterval interval) {
return containsInterval(interval) ? interval
: interval.containsInterval(this) ? this
: interval.contains(start) ? DateInterval(start, interval.end)
: interval.contains(end) ? DateInterval(interval.start, end)
: null;
}