The OpenD Programming Language

PosInfInterval.expand

Expands the interval forwards and/or backwards in time. Effectively, it subtracts the given number of months/years from begin.

  1. void expand(D duration)
  2. void expand(T years, T months, AllowDayOverflow allowOverflow)
    struct PosInfInterval(TP)
    static if(__traits(compiles, begin.add!"months"(1)) && __traits(compiles, begin.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 begin, causing its month to increment.

Throws

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

Examples

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

Meta