| Category | Functions |
|---|---|
| Main types | IntervalDirection |
| Special intervals | everyDayOfWeekeveryMontheveryDuration |
| Special intervals | NegInfIntervalPosInfInterval |
| Underlying ranges | IntervalRangeNegInfIntervalRangePosInfIntervalRange |
| Flags | PopFirst |
Sourcestd/datetime/interval.d
Direction: int;bwdfwdbothPopFirst = std.typecons.Flag!"popFirst".Flag;PopFirst.yes to indicate that the range should havepopFront called on it before the range is returned so thatfront is a time point which the function would generate. To let the first time point not match the generator function, usePopFront.no.PopFirst.yes would tell the function which returned the range thatpopFront was to be called so that front would then be an Easter - the next one generated by the function (which when iterating forward would be the Easter following the originalfront, while when iterating backward, it would be the Easter prior to the originalfront). IfPopFirst.no were used, thenfront would remain the original time point and it would not necessarily be a time point which would be generated by the range-generating function (which in many cases is exactly what is desired - e.g. if iterating over every day starting at the beginning of the interval). If set toPopFirst.no, then popFront is not called before returning the range. Otherwise, if set toPopFirst.yes, then popFront is called before returning the range.Interval(TP);Interval has a starting point and an end point. The interval of time is therefore the time starting at the starting point up to, but not including, the end point. e.g.| [January 5th, 2010 - March 10th, 2010) |
| [05:00:30 - 12:00:00) |
| [1982-01-04T08:59:00 - 2010-07-04T12:00:00) |
Interval, allowing iteration over that interval, with the exact time points which are iterated over depending on the function which generates the range.begin, scope const Uend)TPbegin | The time point which begins the interval. |
Uend | The time point which ends (but is not included in) the interval. |
Example
Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));
begin, scope const Dduration)begin +duration));TPbegin | The time point which begins the interval. |
Dduration | The duration from the starting point to the end point. |
Example
assert(Interval!Date(Date(1996, 1, 2), dur!"days"(3)) == Interval!Date(Date(1996, 1, 2), Date(1996, 1, 5)));
opAssign(ref const Intervalrhs);Intervalrhs | TheInterval to assign to this one. |
opAssign(Intervalrhs);Intervalrhs | TheInterval to assign to this one. |
begin() const;Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).begin == Date(1996, 1, 2));
begin(TPtimePoint);TPtimePoint | The time point to setbegin to. |
end() const;Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).end == Date(2012, 3, 1));
end(TPtimePoint);TPtimePoint | The time point to set end to. |
length() const;Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).length == dur!"days"(5903));
empty() const;Example
assert(Interval!Date(Date(1996, 1, 2), Date(1996, 1, 2)).empty);assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).empty);
contains(scope const TPtimePoint) const;TPtimePoint | The time point to check for inclusion in this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains( Date(1994, 12, 24)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains( Date(2000, 1, 5)));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains( Date(2012, 3, 1)));
contains(scope const Intervalinterval) const;Intervalinterval | The interval to check for inclusion in this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains( Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
contains(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check for inclusion in this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains( PosInfInterval!Date(Date(1999, 5, 4))));
contains(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check for inclusion in this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).contains( NegInfInterval!Date(Date(1996, 5, 4))));
isBefore(scope const TPtimePoint) const;TPtimePoint | The time point to check whether this interval is before it. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( Date(1994, 12, 24)));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( Date(2000, 1, 5)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( Date(2012, 3, 1)));
isBefore(scope const Intervalinterval) const;Intervalinterval | The interval to check for against this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( Interval!Date(Date(2012, 3, 1), Date(2013, 5, 1))));
isBefore(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check for against this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( PosInfInterval!Date(Date(1999, 5, 4))));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( PosInfInterval!Date(Date(2013, 3, 7))));
isBefore(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check for against this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isBefore( NegInfInterval!Date(Date(1996, 5, 4))));
isAfter(scope const TPtimePoint) const;TPtimePoint | The time point to check whether this interval is after it. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter( Date(1994, 12, 24)));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter( Date(2000, 1, 5)));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter( Date(2012, 3, 1)));
isAfter(scope const Intervalinterval) const;Intervalinterval | The interval to check against this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter( Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
isAfter(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check against this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter( PosInfInterval!Date(Date(1999, 5, 4))));
isAfter(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check against this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAfter( NegInfInterval!Date(Date(1996, 1, 2))));
intersects(scope const Intervalinterval) const;Intervalinterval | The interval to check for intersection with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects( Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
intersects(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check for intersection with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects( PosInfInterval!Date(Date(1999, 5, 4))));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects( PosInfInterval!Date(Date(2012, 3, 1))));
intersects(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check for intersection with this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects( NegInfInterval!Date(Date(1996, 1, 2))));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersects( NegInfInterval!Date(Date(2000, 1, 2))));
intersection(scope const Intervalinterval) const;Intervalinterval | The interval to intersect with this interval. |
Example
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)));
intersection(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to intersect with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection( PosInfInterval!Date(Date(1990, 7, 6))) == Interval!Date(Date(1996, 1 , 2), Date(2012, 3, 1)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection( PosInfInterval!Date(Date(1999, 1, 12))) == Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
intersection(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to intersect with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection( NegInfInterval!Date(Date(1999, 7, 6))) == Interval!Date(Date(1996, 1 , 2), Date(1999, 7, 6)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).intersection( NegInfInterval!Date(Date(2013, 1, 12))) == Interval!Date(Date(1996, 1 , 2), Date(2012, 3, 1)));
isAdjacent(scope const Intervalinterval) const;Intervalinterval | The interval to check whether its adjecent to this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent( Interval!Date(Date(1990, 7, 6), Date(1996, 1, 2))));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent( Interval!Date(Date(2012, 3, 1), Date(2013, 9, 17))));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent( Interval!Date(Date(1989, 3, 1), Date(2012, 3, 1))));
isAdjacent(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check whether its adjecent to this interval. |
Example
assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent( PosInfInterval!Date(Date(1999, 5, 4))));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent( PosInfInterval!Date(Date(2012, 3, 1))));
isAdjacent(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check whether its adjecent to this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent( NegInfInterval!Date(Date(1996, 1, 2))));assert(!Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).isAdjacent( NegInfInterval!Date(Date(2000, 1, 2))));
merge(scope const Intervalinterval) const;Intervalinterval | The interval to merge with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge( Interval!Date(Date(2012, 3, 1), Date(2013, 5, 7))) == Interval!Date(Date(1996, 1 , 2), Date(2013, 5, 7)));
merge(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to merge with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge( PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1990, 7 , 6)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge( PosInfInterval!Date(Date(2012, 3, 1))) == PosInfInterval!Date(Date(1996, 1 , 2)));
merge(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to merge with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge( NegInfInterval!Date(Date(1996, 1, 2))) == NegInfInterval!Date(Date(2012, 3 , 1)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).merge( NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2013, 1 , 12)));
span(scope const Intervalinterval) const;Intervalinterval | The interval to create a span together with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span( Interval!Date(Date(1990, 7, 6), Date(1991, 1, 8))) == Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span( Interval!Date(Date(2012, 3, 1), Date(2013, 5, 7))) == Interval!Date(Date(1996, 1 , 2), Date(2013, 5, 7)));
span(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to create a span together with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span( PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1990, 7 , 6)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span( PosInfInterval!Date(Date(2050, 1, 1))) == PosInfInterval!Date(Date(1996, 1 , 2)));
span(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to create a span together with this interval. |
Example
assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span( NegInfInterval!Date(Date(1602, 5, 21))) == NegInfInterval!Date(Date(2012, 3 , 1)));assert(Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1)).span( NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2013, 1 , 12)));
shift(D)(Dduration)duration));Dduration | The duration to shift the interval by. |
Example
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 4, 5));auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 4, 5));interval1.shift(dur!"days"(50));assert(interval1 == Interval!Date(Date(1996, 2, 21), Date(2012, 5, 25)));interval2.shift(dur!"days"(-50));assert(interval2 == Interval!Date(Date(1995, 11, 13), Date(2012, 2, 15)));
shift(T)(Tyears, Tmonths = 0, AllowDayOverflowallowOverflow = AllowDayOverflow.yes)years"() and thenadd!"months"() on begin and end with the given number of years and months.Tyears | The number of years to shift the interval by. |
Tmonths | The number of months to shift the interval by. |
AllowDayOverflowallowOverflow | Whether the days should be allowed to overflow onbegin andend, causing their month to increment. |
Example
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));interval1.shift(2);assert(interval1 == Interval!Date(Date(1998, 1, 2), Date(2014, 3, 1)));interval2.shift(-2);assert(interval2 == Interval!Date(Date(1994, 1, 2), Date(2010, 3, 1)));
expand(D)(Dduration, Directiondir = Direction.both)duration));Dduration | The duration to expand the interval by. |
Directiondir | The direction in time to expand the interval. |
Example
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));interval1.expand(2);assert(interval1 == Interval!Date(Date(1994, 1, 2), Date(2014, 3, 1)));interval2.expand(-2);assert(interval2 == Interval!Date(Date(1998, 1, 2), Date(2010, 3, 1)));
expand(T)(Tyears, Tmonths = 0, AllowDayOverflowallowOverflow = AllowDayOverflow.yes, Directiondir = Direction.both)Tyears | The number of years to expand the interval by. |
Tmonths | The number of months to expand the interval by. |
AllowDayOverflowallowOverflow | Whether the days should be allowed to overflow onbegin andend, causing their month to increment. |
Directiondir | The direction in time to expand the interval. |
Example
auto interval1 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));auto interval2 = Interval!Date(Date(1996, 1, 2), Date(2012, 3, 1));interval1.expand(2);assert(interval1 == Interval!Date(Date(1994, 1, 2), Date(2014, 3, 1)));interval2.expand(-2);assert(interval2 == Interval!Date(Date(1998, 1, 2), Date(2010, 3, 1)));
fwdRange(TP delegate(scope const TP)func, PopFirstpopFirst = PopFirst.no) const;fwdRange. Their documentation starts with "Range-generating function," making them easily searchable.TP delegate(scope const TP)func | The function used to generate the time points of the range over the interval. |
PopFirstpopFirst | WhetherpopFront should be called on the range before returning it. |
Warningfunc must be logically pure. Ideally,func would be a function pointer to a pure function, but forcingfunc to be pure is far too restrictive to be useful, and in order to have the ease of use of having functions which generate functions to pass tofwdRange,func must be a delegate.
fwdRange. Iffunc is given the same time point with two different calls, it must return the same result both times. Of course, none of the functions in this module have this problem, so it's only relevant if when creating a custom delegate.Example
auto interval = Interval!Date(Date(2010, 9, 1), Date(2010, 9, 9));autofunc =delegate (scopeconst Date date)// For iterating over even-numbered days. {if ((date.day & 1) == 0)return date + dur!"days"(2);return date + dur!"days"(1); };auto range = interval.fwdRange(func);// An odd day. Using PopFirst.yes would have made this Date(2010, 9, 2).assert(range.front == Date(2010, 9, 1));range.popFront();assert(range.front == Date(2010, 9, 2));range.popFront();assert(range.front == Date(2010, 9, 4));range.popFront();assert(range.front == Date(2010, 9, 6));range.popFront();assert(range.front == Date(2010, 9, 8));range.popFront();assert(range.empty);
bwdRange(TP delegate(scope const TP)func, PopFirstpopFirst = PopFirst.no) const;bwdRange. Their documentation starts with "Range-generating function," making them easily searchable.TP delegate(scope const TP)func | The function used to generate the time points of the range over the interval. |
PopFirstpopFirst | WhetherpopFront should be called on the range before returning it. |
Warningfunc must be logically pure. Ideally,func would be a function pointer to a pure function, but forcingfunc to be pure is far too restrictive to be useful, and in order to have the ease of use of having functions which generate functions to pass tofwdRange,func must be a delegate.
Iffunc retains state which changes as it is called, then some algorithms will not work correctly, because the range'ssave will have failed to have really saved the range's state. To avoid such bugs, don't pass a delegate which is not logically pure tofwdRange. Iffunc is given the same time point with two different calls, it must return the same result both times. Of course, none of the functions in this module have this problem, so it's only relevant for custom delegates.Example
auto interval = Interval!Date(Date(2010, 9, 1), Date(2010, 9, 9));autofunc =delegate (scopeconst Date date)// For iterating over even-numbered days. {if ((date.day & 1) == 0)return date - dur!"days"(2);return date - dur!"days"(1); };auto range = interval.bwdRange(func);// An odd day. Using PopFirst.yes would have made this Date(2010, 9, 8).assert(range.front == Date(2010, 9, 9));range.popFront();assert(range.front == Date(2010, 9, 8));range.popFront();assert(range.front == Date(2010, 9, 6));range.popFront();assert(range.front == Date(2010, 9, 4));range.popFront();assert(range.front == Date(2010, 9, 2));range.popFront();assert(range.empty);
toString() const;toString(Writer)(ref Writerw) constWriterw | Achar acceptingoutput range |
PosInfInterval(TP);PosInfInterval are infinite. So, the main purpose of usingPosInfInterval is to create an infinite range which starts at a fixed point in time and goes to positive infinity.begin);TPbegin | The time point which begins the interval. |
Example
auto interval = PosInfInterval!Date(Date(1996, 1, 2));opAssign(ref const PosInfIntervalrhs);PosInfIntervalrhs | ThePosInfInterval to assign to this one. |
opAssign(PosInfIntervalrhs);PosInfIntervalrhs | ThePosInfInterval to assign to this one. |
begin() const;Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).begin == Date(1996, 1, 2));
begin(TPtimePoint);TPtimePoint | The time point to setbegin to. |
empty;Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).empty);
contains(TPtimePoint) const;TPtimePoint | The time point to check for inclusion in this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains(Date(1994, 12, 24)));assert(PosInfInterval!Date(Date(1996, 1, 2)).contains(Date(2000, 1, 5)));
contains(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check for inclusion in this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(PosInfInterval!Date(Date(1996, 1, 2)).contains( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(PosInfInterval!Date(Date(1996, 1, 2)).contains( Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
contains(scope const PosInfIntervalinterval) const;PosInfIntervalinterval | The interval to check for inclusion in this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).contains( PosInfInterval!Date(Date(1999, 5, 4))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains( PosInfInterval!Date(Date(1995, 7, 2))));
contains(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check for inclusion in this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).contains( NegInfInterval!Date(Date(1996, 5, 4))));
isBefore(scope const TPtimePoint) const;TPtimePoint | The time point to check whether this interval is before it. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Date(1994, 12, 24)));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore(Date(2000, 1, 5)));
isBefore(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check for against this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
isBefore(scope const PosInfIntervalinterval) const;PosInfIntervalinterval | The interval to check for against this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore( PosInfInterval!Date(Date(1992, 5, 4))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore( PosInfInterval!Date(Date(2013, 3, 7))));
isBefore(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check for against this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isBefore( NegInfInterval!Date(Date(1996, 5, 4))));
isAfter(scope const TPtimePoint) const;TPtimePoint | The time point to check whether this interval is after it. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Date(1994, 12, 24)));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter(Date(2000, 1, 5)));
isAfter(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check against this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter( Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
isAfter(scope const PosInfIntervalinterval) const;PosInfIntervalinterval | The interval to check against this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter( PosInfInterval!Date(Date(1990, 1, 7))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter( PosInfInterval!Date(Date(1999, 5, 4))));
isAfter(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check against this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAfter( NegInfInterval!Date(Date(1996, 1, 2))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAfter( NegInfInterval!Date(Date(2000, 7, 1))));
intersects(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check for intersection with this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).intersects( Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));
intersects(scope const PosInfIntervalinterval) const;PosInfIntervalinterval | The interval to check for intersection with this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects( PosInfInterval!Date(Date(1990, 1, 7))));assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects( PosInfInterval!Date(Date(1999, 5, 4))));
intersects(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check for intersection with this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).intersects( NegInfInterval!Date(Date(1996, 1, 2))));assert(PosInfInterval!Date(Date(1996, 1, 2)).intersects( NegInfInterval!Date(Date(2000, 7, 1))));
intersection(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to intersect with this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == Interval!Date(Date(1996, 1 , 2), Date(2000, 8, 2)));assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) == Interval!Date(Date(1999, 1 , 12), Date(2011, 9, 17)));
intersection(scope const PosInfIntervalinterval) const;PosInfIntervalinterval | The interval to intersect with this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection( PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1996, 1 , 2)));assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection( PosInfInterval!Date(Date(1999, 1, 12))) == PosInfInterval!Date(Date(1999, 1 , 12)));
intersection(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to intersect with this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection( NegInfInterval!Date(Date(1999, 7, 6))) == Interval!Date(Date(1996, 1 , 2), Date(1999, 7, 6)));assert(PosInfInterval!Date(Date(1996, 1, 2)).intersection( NegInfInterval!Date(Date(2013, 1, 12))) == Interval!Date(Date(1996, 1 , 2), Date(2013, 1, 12)));
isAdjacent(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check whether its adjecent to this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent( Interval!Date(Date(1989, 3, 1), Date(1996, 1, 2))));assert(!PosInfInterval!Date(Date(1999, 1, 12)).isAdjacent( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));
isAdjacent(scope const PosInfIntervalinterval) const;PosInfIntervalinterval | The interval to check whether its adjecent to this interval. |
Example
assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent( PosInfInterval!Date(Date(1990, 1, 7))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent( PosInfInterval!Date(Date(1996, 1, 2))));
isAdjacent(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check whether its adjecent to this interval. |
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent( NegInfInterval!Date(Date(1996, 1, 2))));assert(!PosInfInterval!Date(Date(1996, 1, 2)).isAdjacent( NegInfInterval!Date(Date(2000, 7, 1))));
merge(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to merge with this interval. |
NoteThere is no overload formerge which takes aNegInfInterval, because an interval going from negative infinity to positive infinity is not possible.
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == PosInfInterval!Date(Date(1990, 7 , 6)));assert(PosInfInterval!Date(Date(1996, 1, 2)).merge( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) == PosInfInterval!Date(Date(1996, 1 , 2)));
merge(scope const PosInfIntervalinterval) const;PosInfIntervalinterval | The interval to merge with this interval. |
NoteThere is no overload formerge which takes aNegInfInterval, because an interval going from negative infinity to positive infinity is not possible.
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).merge( PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1990, 7 , 6)));assert(PosInfInterval!Date(Date(1996, 1, 2)).merge( PosInfInterval!Date(Date(1999, 1, 12))) == PosInfInterval!Date(Date(1996, 1 , 2)));
span(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to create a span together with this interval. |
NoteThere is no overload forspan which takes aNegInfInterval, because an interval going from negative infinity to positive infinity is not possible.
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).span( Interval!Date(Date(500, 8, 9), Date(1602, 1, 31))) == PosInfInterval!Date(Date(500, 8, 9)));assert(PosInfInterval!Date(Date(1996, 1, 2)).span( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == PosInfInterval!Date(Date(1990, 7 , 6)));assert(PosInfInterval!Date(Date(1996, 1, 2)).span( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))) == PosInfInterval!Date(Date(1996, 1 , 2)));
span(scope const PosInfIntervalinterval) const;PosInfIntervalinterval | The interval to create a span together with this interval. |
NoteThere is no overload forspan which takes aNegInfInterval, because an interval going from negative infinity to positive infinity is not possible.
Example
assert(PosInfInterval!Date(Date(1996, 1, 2)).span( PosInfInterval!Date(Date(1990, 7, 6))) == PosInfInterval!Date(Date(1990, 7 , 6)));assert(PosInfInterval!Date(Date(1996, 1, 2)).span( PosInfInterval!Date(Date(1999, 1, 12))) == PosInfInterval!Date(Date(1996, 1 , 2)));
shift(D)(Dduration)duration));Dduration | The duration to shift the interval by. |
Example
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));interval1.shift(dur!"days"(50));assert(interval1 == PosInfInterval!Date(Date(1996, 2, 21)));interval2.shift(dur!"days"(-50));assert(interval2 == PosInfInterval!Date(Date(1995, 11, 13)));
shift(T)(Tyears, Tmonths = 0, AllowDayOverflowallowOverflow = AllowDayOverflow.yes)years"() and thenadd!"months"() onbegin with the given number of years and months.Tyears | The number of years to shift the interval by. |
Tmonths | The number of months to shift the interval by. |
AllowDayOverflowallowOverflow | Whether the days should be allowed to overflow onbegin, causing its month to increment. |
Example
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));interval1.shift(dur!"days"(50));assert(interval1 == PosInfInterval!Date(Date(1996, 2, 21)));interval2.shift(dur!"days"(-50));assert(interval2 == PosInfInterval!Date(Date(1995, 11, 13)));
expand(D)(Dduration)duration));Dduration | The duration to expand the interval by. |
Example
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));interval1.expand(dur!"days"(2));assert(interval1 == PosInfInterval!Date(Date(1995, 12, 31)));interval2.expand(dur!"days"(-2));assert(interval2 == PosInfInterval!Date(Date(1996, 1, 4)));
expand(T)(Tyears, Tmonths = 0, AllowDayOverflowallowOverflow = AllowDayOverflow.yes)Tyears | The number of years to expand the interval by. |
Tmonths | The number of months to expand the interval by. |
AllowDayOverflowallowOverflow | Whether the days should be allowed to overflow onbegin, causing its month to increment. |
Example
auto interval1 = PosInfInterval!Date(Date(1996, 1, 2));auto interval2 = PosInfInterval!Date(Date(1996, 1, 2));interval1.expand(2);assert(interval1 == PosInfInterval!Date(Date(1994, 1, 2)));interval2.expand(-2);assert(interval2 == PosInfInterval!Date(Date(1998, 1, 2)));
fwdRange(TP delegate(scope const TP)func, PopFirstpopFirst = PopFirst.no) const;fwdRange. Their documentation starts with "Range-generating function," to make them easily searchable.TP delegate(scope const TP)func | The function used to generate the time points of the range over the interval. |
PopFirstpopFirst | WhetherpopFront should be called on the range before returning it. |
Warningfunc must be logically pure. Ideally,func would be a function pointer to a pure function, but forcingfunc to be pure is far too restrictive to be useful, and in order to have the ease of use of having functions which generate functions to pass tofwdRange,func must be a delegate.
fwdRange. Iffunc is given the same time point with two different calls, it must return the same result both times. Of course, none of the functions in this module have this problem, so it's only relevant for custom delegates.Example
auto interval = PosInfInterval!Date(Date(2010, 9, 1));autofunc =delegate (scopeconst Date date)//For iterating over even-numbered days. {if ((date.day & 1) == 0)return date + dur!"days"(2);return date + dur!"days"(1); };auto range = interval.fwdRange(func);//An odd day. Using PopFirst.yes would have made this Date(2010, 9, 2).assert(range.front == Date(2010, 9, 1));range.popFront();assert(range.front == Date(2010, 9, 2));range.popFront();assert(range.front == Date(2010, 9, 4));range.popFront();assert(range.front == Date(2010, 9, 6));range.popFront();assert(range.front == Date(2010, 9, 8));range.popFront();assert(!range.empty);
toString() const;NegInfInterval(TP);NegInfInterval are infinite. So, the main purpose of usingNegInfInterval is to create an infinite range which starts at negative infinity and goes to a fixed end point. Iterate over it in reverse.end);TPend | The time point which ends the interval. |
Example
auto interval = PosInfInterval!Date(Date(1996, 1, 2));opAssign(ref const NegInfIntervalrhs);NegInfIntervalrhs | TheNegInfInterval to assign to this one. |
opAssign(NegInfIntervalrhs);NegInfIntervalrhs | TheNegInfInterval to assign to this one. |
end() const;Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).end == Date(2012, 3, 1));
end(TPtimePoint);TPtimePoint | The time point to set end to. |
empty;Example
assert(!NegInfInterval!Date(Date(1996, 1, 2)).empty);
contains(TPtimePoint) const;TPtimePoint | The time point to check for inclusion in this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(1994, 12, 24)));assert(NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(2000, 1, 5)));assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains(Date(2012, 3, 1)));
contains(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check for inclusion in this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(NegInfInterval!Date(Date(2012, 3, 1)).contains( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains( Interval!Date(Date(1998, 2, 28), Date(2013, 5, 1))));
contains(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check for inclusion in this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains( PosInfInterval!Date(Date(1999, 5, 4))));
contains(scope const NegInfIntervalinterval) const;NegInfIntervalinterval | The interval to check for inclusion in this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).contains( NegInfInterval!Date(Date(1996, 5, 4))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).contains( NegInfInterval!Date(Date(2013, 7, 9))));
isBefore(scope const TPtimePoint) const;TPtimePoint | The time point to check whether this interval is before it. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(1994, 12, 24)));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(2000, 1, 5)));assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore(Date(2012, 3, 1)));
isBefore(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check for against this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore( Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
isBefore(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check for against this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore( PosInfInterval!Date(Date(1999, 5, 4))));assert(NegInfInterval!Date(Date(2012, 3, 1)).isBefore( PosInfInterval!Date(Date(2012, 3, 1))));
isBefore(scope const NegInfIntervalinterval) const;NegInfIntervalinterval | The interval to check for against this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore( NegInfInterval!Date(Date(1996, 5, 4))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isBefore( NegInfInterval!Date(Date(2013, 7, 9))));
isAfter(scope const TPtimePoint) const;TPtimePoint | The time point to check whether this interval is after it. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(1994, 12, 24)));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(2000, 1, 5)));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter(Date(2012, 3, 1)));
isAfter(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check against this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter( Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
isAfter(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check against this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter( PosInfInterval!Date(Date(1999, 5, 4))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter( PosInfInterval!Date(Date(2012, 3, 1))));
isAfter(scope const NegInfIntervalinterval) const;NegInfIntervalinterval | The interval to check against this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter( NegInfInterval!Date(Date(1996, 5, 4))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAfter( NegInfInterval!Date(Date(2013, 7, 9))));
intersects(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check for intersection with this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects( Interval!Date(Date(1999, 1, 12), Date(2011, 9, 17))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).intersects( Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
intersects(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check for intersection with this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects( PosInfInterval!Date(Date(1999, 5, 4))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).intersects( PosInfInterval!Date(Date(2012, 3, 1))));
intersects(scope const NegInfInterval!TPinterval) const;NegInfInterval!TPinterval | The interval to check for intersection with this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects( NegInfInterval!Date(Date(1996, 5, 4))));assert(NegInfInterval!Date(Date(2012, 3, 1)).intersects( NegInfInterval!Date(Date(2013, 7, 9))));
intersection(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to intersect with this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == Interval!Date(Date(1990, 7 , 6), Date(2000, 8, 2)));assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection( Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) == Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
intersection(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to intersect with this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection( PosInfInterval!Date(Date(1990, 7, 6))) == Interval!Date(Date(1990, 7 , 6), Date(2012, 3, 1)));assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection( PosInfInterval!Date(Date(1999, 1, 12))) == Interval!Date(Date(1999, 1 , 12), Date(2012, 3, 1)));
intersection(scope const NegInfIntervalinterval) const;NegInfIntervalinterval | The interval to intersect with this interval. |
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection( NegInfInterval!Date(Date(1999, 7, 6))) == NegInfInterval!Date(Date(1999, 7 , 6)));assert(NegInfInterval!Date(Date(2012, 3, 1)).intersection( NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2012, 3 , 1)));
isAdjacent(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to check whether its adjecent to this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent( Interval!Date(Date(1999, 1, 12), Date(2012, 3, 1))));assert(NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent( Interval!Date(Date(2012, 3, 1), Date(2019, 2, 2))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent( Interval!Date(Date(2022, 10, 19), Date(2027, 6, 3))));
isAdjacent(scope const PosInfInterval!TPinterval) const;PosInfInterval!TPinterval | The interval to check whether its adjecent to this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent( PosInfInterval!Date(Date(1999, 5, 4))));assert(NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent( PosInfInterval!Date(Date(2012, 3, 1))));
isAdjacent(scope const NegInfIntervalinterval) const;NegInfIntervalinterval | The interval to check whether its adjecent to this interval. |
Example
assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent( NegInfInterval!Date(Date(1996, 5, 4))));assert(!NegInfInterval!Date(Date(2012, 3, 1)).isAdjacent( NegInfInterval!Date(Date(2012, 3, 1))));
merge(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to merge with this interval. |
NoteThere is no overload formerge which takes aPosInfInterval, because an interval going from negative infinity to positive infinity is not possible.
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == NegInfInterval!Date(Date(2012, 3 , 1)));assert(NegInfInterval!Date(Date(2012, 3, 1)).merge( Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) == NegInfInterval!Date(Date(2015, 9 , 2)));
merge(scope const NegInfIntervalinterval) const;NegInfIntervalinterval | The interval to merge with this interval. |
NoteThere is no overload formerge which takes aPosInfInterval, because an interval going from negative infinity to positive infinity is not possible.
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).merge( NegInfInterval!Date(Date(1999, 7, 6))) == NegInfInterval!Date(Date(2012, 3 , 1)));assert(NegInfInterval!Date(Date(2012, 3, 1)).merge( NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2013, 1 , 12)));
span(scope const Interval!TPinterval) const;Interval!TPinterval | The interval to create a span together with this interval. |
NoteThere is no overload forspan which takes aPosInfInterval, because an interval going from negative infinity to positive infinity is not possible.
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).span( Interval!Date(Date(1990, 7, 6), Date(2000, 8, 2))) == NegInfInterval!Date(Date(2012, 3 , 1)));assert(NegInfInterval!Date(Date(2012, 3, 1)).span( Interval!Date(Date(1999, 1, 12), Date(2015, 9, 2))) == NegInfInterval!Date(Date(2015, 9 , 2)));assert(NegInfInterval!Date(Date(1600, 1, 7)).span( Interval!Date(Date(2012, 3, 11), Date(2017, 7, 1))) == NegInfInterval!Date(Date(2017, 7 , 1)));
span(scope const NegInfIntervalinterval) const;NegInfIntervalinterval | The interval to create a span together with this interval. |
NoteThere is no overload forspan which takes aPosInfInterval, because an interval going from negative infinity to positive infinity is not possible.
Example
assert(NegInfInterval!Date(Date(2012, 3, 1)).span( NegInfInterval!Date(Date(1999, 7, 6))) == NegInfInterval!Date(Date(2012, 3 , 1)));assert(NegInfInterval!Date(Date(2012, 3, 1)).span( NegInfInterval!Date(Date(2013, 1, 12))) == NegInfInterval!Date(Date(2013, 1 , 12)));
shift(D)(Dduration)duration));Dduration | The duration to shift the interval by. |
Example
auto interval1 = NegInfInterval!Date(Date(2012, 4, 5));auto interval2 = NegInfInterval!Date(Date(2012, 4, 5));interval1.shift(dur!"days"(50));assert(interval1 == NegInfInterval!Date(Date(2012, 5, 25)));interval2.shift(dur!"days"(-50));assert(interval2 == NegInfInterval!Date( Date(2012, 2, 15)));
shift(T)(Tyears, Tmonths = 0, AllowDayOverflowallowOverflow = AllowDayOverflow.yes)years"() and thenadd!"months"() on end with the given number of years and months.Tyears | The number of years to shift the interval by. |
Tmonths | The number of months to shift the interval by. |
AllowDayOverflowallowOverflow | Whether the days should be allowed to overflow onend, causing its month to increment. |
Example
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));interval1.shift(2);assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));interval2.shift(-2);assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));
expand(D)(Dduration)duration));Dduration | The duration to expand the interval by. |
Example
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));interval1.expand(dur!"days"(2));assert(interval1 == NegInfInterval!Date(Date(2012, 3, 3)));interval2.expand(dur!"days"(-2));assert(interval2 == NegInfInterval!Date(Date(2012, 2, 28)));
expand(T)(Tyears, Tmonths = 0, AllowDayOverflowallowOverflow = AllowDayOverflow.yes)Tyears | The number of years to expand the interval by. |
Tmonths | The number of months to expand the interval by. |
AllowDayOverflowallowOverflow | Whether the days should be allowed to overflow onend, causing their month to increment. |
Example
auto interval1 = NegInfInterval!Date(Date(2012, 3, 1));auto interval2 = NegInfInterval!Date(Date(2012, 3, 1));interval1.expand(2);assert(interval1 == NegInfInterval!Date(Date(2014, 3, 1)));interval2.expand(-2);assert(interval2 == NegInfInterval!Date(Date(2010, 3, 1)));
bwdRange(TP delegate(scope const TP)func, PopFirstpopFirst = PopFirst.no) const;bwdRange. Their documentation starts with "Range-generating function," to make them easily searchable.TP delegate(scope const TP)func | The function used to generate the time points of the range over the interval. |
PopFirstpopFirst | WhetherpopFront should be called on the range before returning it. |
Warningfunc must be logically pure. Ideally,func would be a function pointer to a pure function, but forcingfunc to be pure is far too restrictive to be useful, and in order to have the ease of use of having functions which generate functions to pass tofwdRange,func must be a delegate.
Iffunc retains state which changes as it is called, then some algorithms will not work correctly, because the range'ssave will have failed to have really saved the range's state. To avoid such bugs, don't pass a delegate which is not logically pure tofwdRange. Iffunc is given the same time point with two different calls, it must return the same result both times. Of course, none of the functions in this module have this problem, so it's only relevant for custom delegates.Example
auto interval = NegInfInterval!Date(Date(2010, 9, 9));autofunc =delegate (scopeconst Date date)//For iterating over even-numbered days. {if ((date.day & 1) == 0)return date - dur!"days"(2);return date - dur!"days"(1); };auto range = interval.bwdRange(func);assert(range.front == Date(2010, 9, 9));//An odd day. Using PopFirst.yes would have made this Date(2010, 9, 8).range.popFront();assert(range.front == Date(2010, 9, 8));range.popFront();assert(range.front == Date(2010, 9, 6));range.popFront();assert(range.front == Date(2010, 9, 4));range.popFront();assert(range.front == Date(2010, 9, 2));range.popFront();assert(!range.empty);
toString() const;everyDayOfWeek(TP, Direction dir = Direction.fwd)(DayOfWeekdayOfWeek)dayOfWeek") && !__traits(isStaticFunction, TP.dayOfWeek) && is(typeof(TP.dayOfWeek) == DayOfWeek));everyDayOfWeek would result in a delegate which could be used to iterate over all of the Mondays in a range.| dir | The direction to iterate in. If passing the return value tofwdRange, useDirection.fwd. If passing it tobwdRange, useDirection.bwd. |
DayOfWeekdayOfWeek | The week that each time point in the range will be. |
import std.datetime.date : Date, DayOfWeek;auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));auto func =everyDayOfWeek!Date(DayOfWeek.mon);auto range = interval.fwdRange(func);// A Thursday. Using PopFirst.yes would have made this Date(2010, 9, 6).writeln(range.front);// Date(2010, 9, 2)range.popFront();writeln(range.front);// Date(2010, 9, 6)range.popFront();writeln(range.front);// Date(2010, 9, 13)range.popFront();writeln(range.front);// Date(2010, 9, 20)range.popFront();assert(range.empty);
everyMonth(TP, Direction dir = Direction.fwd)(intmonth)month") && !__traits(isStaticFunction, TP.month) && is(typeof(TP.month) == Month));everyMonth to create the delegate. Since it wouldn't really make sense to be iterating over a specific month and end up with some of the time points in the succeeding month or two years after the previous time point,AllowDayOverflow.no is always used when calculating the next time point.| dir | The direction to iterate in. If passing the return value tofwdRange, useDirection.fwd. If passing it tobwdRange, useDirection.bwd. |
intmonth | The month that each time point in the range will be in (January is 1). |
import std.datetime.date : Date, Month;auto interval = Interval!Date(Date(2000, 1, 30), Date(2004, 8, 5));auto func =everyMonth!Date(Month.feb);auto range = interval.fwdRange(func);// Using PopFirst.yes would have made this Date(2010, 2, 29).writeln(range.front);// Date(2000, 1, 30)range.popFront();writeln(range.front);// Date(2000, 2, 29)range.popFront();writeln(range.front);// Date(2001, 2, 28)range.popFront();writeln(range.front);// Date(2002, 2, 28)range.popFront();writeln(range.front);// Date(2003, 2, 28)range.popFront();writeln(range.front);// Date(2004, 2, 28)range.popFront();assert(range.empty);
everyDuration(TP, Direction dir = Direction.fwd, D)(Dduration)duration) && (dir == Direction.fwd || dir == Direction.bwd));everyDuration would result in a delegate which could be used to iterate over a range of days which are each 3 days apart.| dir | The direction to iterate in. If passing the return value tofwdRange, useDirection.fwd. If passing it tobwdRange, useDirection.bwd. |
Dduration | The duration which separates each successive time point in the range. |
import core.time : dur;import std.datetime.date : Date;auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));auto func =everyDuration!Date(dur!"days"(8));auto range = interval.fwdRange(func);// Using PopFirst.yes would have made this Date(2010, 9, 10).writeln(range.front);// Date(2010, 9, 2)range.popFront();writeln(range.front);// Date(2010, 9, 10)range.popFront();writeln(range.front);// Date(2010, 9, 18)range.popFront();writeln(range.front);// Date(2010, 9, 26)range.popFront();assert(range.empty);
everyDuration(TP, Direction dir = Direction.fwd, D)(intyears, intmonths = 0, AllowDayOverflowallowOverflow = AllowDayOverflow.yes, Dduration = dur!"days"(0))duration) && __traits(compiles, TP.init.add!"years"(years)) && __traits(compiles, TP.init.add!"months"(months)) && (dir == Direction.fwd || dir == Direction.bwd));everyDuration and the version which just takes acore.time.Duration is that this one also takes the number of years and months (along with anAllowDayOverflow to indicate whether adding years and months should allow the days to overflow). Note that if iterating forward,add!"years"() is called on the given time point, thenadd!"months"(), and finally the duration is added to it. However, if iterating backwards, the duration is added first, thenadd!"months"() is called, and finallyadd!"years"() is called. That way, going backwards generates close to the same time points that iterating forward does, but since adding years and months is not entirely reversible (due to possible day overflow, regardless of whetherAllowDayOverflow.yes orAllowDayOverflow.no is used), it can't be guaranteed that iterating backwards will give the same time points as iterating forward would have (even assuming that the end of the range is a time point which would be returned by the delegate when iterating forward frombegin).| dir | The direction to iterate in. If passing the return value tofwdRange, useDirection.fwd. If passing it tobwdRange, useDirection.bwd. |
intyears | The number of years to add to the time point passed to the delegate. |
intmonths | The number of months to add to the time point passed to the delegate. |
AllowDayOverflowallowOverflow | Whether the days should be allowed to overflow onbegin andend, causing their month to increment. |
Dduration | The duration to add to the time point passed to the delegate. |
import core.time : dur;import std.datetime.date : AllowDayOverflow, Date;auto interval = Interval!Date(Date(2010, 9, 2), Date(2025, 9, 27));auto func =everyDuration!Date(4, 1, AllowDayOverflow.yes, dur!"days"(2));auto range = interval.fwdRange(func);// Using PopFirst.yes would have made this Date(2014, 10, 12).writeln(range.front);// Date(2010, 9, 2)range.popFront();writeln(range.front);// Date(2014, 10, 4)range.popFront();writeln(range.front);// Date(2018, 11, 6)range.popFront();writeln(range.front);// Date(2022, 12, 8)range.popFront();assert(range.empty);
IntervalRange(TP, Direction dir) if (isTimePoint!TP && (dir != Direction.both));IntervalRange is only ever constructed byInterval. However, when it is constructed, it is given a function,func, which is used to generate the time points which are iterated over.func takes a time point and returns a time point of the same type. For instance, to iterate over all of the days in the intervalInterval!Date, pass a function toInterval'sfwdRange where that function took astd.datetime.date.Date and returned astd.datetime.date.Date which was one day later. That function would then be used byIntervalRange'spopFront to iterate over thestd.datetime.date.Dates in the interval. Ifdir == Direction.fwd, then a range iterates forward in time, whereas ifdir == Direction.bwd, then it iterates backwards in time. So, ifdir == Direction.fwd thenfront == interval.begin, whereas ifdir == Direction.bwd thenfront == interval.end.func must generate a time point going in the proper direction of iteration, or astd.datetime.date.DateTimeException will be thrown. So, to iterate forward in time, the time point thatfunc generates must be later in time than the one passed to it. If it's either identical or earlier in time, then astd.datetime.date.DateTimeException will be thrown. To iterate backwards, then the generated time point must be before the time point which was passed in. If the generated time point is ever passed the edge of the range in the proper direction, then the edge of that range will be used instead. So, if iterating forward, and the generated time point is past the interval'send, thenfront becomesend. If iterating backwards, and the generated time point is beforebegin, thenfront becomesbegin. In either case, the range would then be empty. Also note that while normally thebegin of an interval is included in it and itsend is excluded from it, ifdir == Direction.bwd, thenbegin is treated as excluded andend is treated as included. This allows for the same behavior in both directions. This works because none ofInterval's functions which care about whetherbegin orend is included or excluded are ever called byIntervalRange.interval returns a normal interval, regardless of whetherdir == Direction.fwd or ifdir == Direction.bwd, so anyInterval functions which are called on it which care about whetherbegin orend are included or excluded will treatbegin as included andend as excluded.opAssign(ref IntervalRangerhs);opAssign(IntervalRangerhs);IntervalRangerhs | TheIntervalRange to assign to this one. |
empty() const;front() const;popFront();save();interval() const;func();direction() const;PosInfIntervalRange(TP) if (isTimePoint!TP);PosInfIntervalRange is only ever constructed byPosInfInterval. However, when it is constructed, it is given a function,func, which is used to generate the time points which are iterated over.func takes a time point and returns a time point of the same type. For instance, to iterate over all of the days in the intervalPosInfInterval!Date, pass a function toPosInfInterval'sfwdRange where that function took astd.datetime.date.Date and returned astd.datetime.date.Date which was one day later. That function would then be used byPosInfIntervalRange'spopFront to iterate over thestd.datetime.date.Dates in the interval - though obviously, since the range is infinite, use a function such asstd.range.take with it rather than iterating overall of the dates. As the interval goes to positive infinity, the range is always iterated over forwards, never backwards.func must generate a time point going in the proper direction of iteration, or astd.datetime.date.DateTimeException will be thrown. So, the time points thatfunc generates must be later in time than the one passed to it. If it's either identical or earlier in time, then astd.datetime.date.DateTimeException will be thrown.opAssign(ref PosInfIntervalRangerhs);opAssign(PosInfIntervalRangerhs);PosInfIntervalRangerhs | ThePosInfIntervalRange to assign to this one. |
empty;front() const;popFront();save();interval() const;func();NegInfIntervalRange(TP) if (isTimePoint!TP);NegInfIntervalRange is only ever constructed byNegInfInterval. However, when it is constructed, it is given a function,func, which is used to generate the time points which are iterated over.func takes a time point and returns a time point of the same type. For instance, to iterate over all of the days in the intervalNegInfInterval!Date, pass a function toNegInfInterval'sbwdRange where that function took astd.datetime.date.Date and returned astd.datetime.date.Date which was one day earlier. That function would then be used byNegInfIntervalRange'spopFront to iterate over thestd.datetime.date.Dates in the interval - though obviously, since the range is infinite, use a function such asstd.range.take with it rather than iterating overall of the dates. As the interval goes to negative infinity, the range is always iterated over backwards, never forwards.func must generate a time point going in the proper direction of iteration, or astd.datetime.date.DateTimeException will be thrown. So, the time points thatfunc generates must be earlier in time than the one passed to it. If it's either identical or later in time, then astd.datetime.date.DateTimeException will be thrown. Also note that while normally theend of an interval is excluded from it,NegInfIntervalRange treats it as if it were included. This allows for the same behavior as withPosInfIntervalRange. This works because none ofNegInfInterval's functions which care about whetherend is included or excluded are ever called byNegInfIntervalRange.interval returns a normal interval, so anyNegInfInterval functions which are called on it which care about whetherend is included or excluded will treatend as excluded.opAssign(ref NegInfIntervalRangerhs);opAssign(NegInfIntervalRangerhs);NegInfIntervalRangerhs | TheNegInfIntervalRange to assign to this one. |
empty;front() const;popFront();save();interval() const;func();