The OpenD Programming Language

PosInfInterval.shift

Shifts the begin of this interval forward or backwards in time by the given duration (a positive duration shifts the interval forward; a negative duration shifts it backward). Effectively, it does begin += duration.

  1. void shift(D duration)
    struct PosInfInterval(TP)
    pure nothrow
    void
    shift
    (
    D
    )
    if (
    __traits(compiles, begin + duration)
    )
  2. void shift(T years, T months, AllowDayOverflow allowOverflow)

Parameters

duration D

The duration to shift the interval by.

Examples

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

Meta