Interval.intersection

Returns the intersection of two intervals

  1. Interval intersection(Interval interval)
    struct Interval(TP)
    const
    intersection
    (
    scope const Interval interval
    )
  2. Interval intersection(PosInfInterval!TP interval)
  3. Interval intersection(NegInfInterval!TP interval)

Parameters

interval Interval

The interval to intersect with this interval.

Throws

std.datetime.date.DateTimeException if the two intervals do not intersect or if either interval is empty.

Examples

assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
            Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) ==
       Interval!Date(Date(1996, 1 , 2), Date(2000, 8, 2)));

assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection(
            Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) ==
       Interval!Date(Date(1999, 1 , 12), Date(2011, 9, 17)));

Meta