The OpenD Programming Language

NegInfInterval.expand

Expands the interval forwards and/or backwards in time. Effectively, it adds the given number of months/years to end.

  1. void expand(D duration)
  2. void expand(T years, T months, AllowDayOverflow allowOverflow)
    struct NegInfInterval(TP)
    static if(__traits(compiles, end.add!"months"(1)) && __traits(compiles, end.add!"years"(1)))
    void
    expand
    (
    T
    )

Parameters

years T

The number of years to expand the interval by.

months T

The number of months to expand the interval by.

allowOverflow AllowDayOverflow

Whether the days should be allowed to overflow on end, causing their month to increment.

Throws

std.datetime.date.DateTimeException if empty is true or if the resulting interval would be invalid.

Examples

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)));

Meta