The OpenD Programming Language

YearMonth.add

  1. YearMonth add(long months)
  2. YearMonth add(long quarters)
    struct YearMonth
    nothrow deprecated @safe pure nothrow @nogc ref
    add
    (
    string units : "quarters"
    )
    ()
  3. YearMonth add(long years)

Examples

auto yq0 = YearMonth(2020, Month.jan);

yq0.add!"quarters"(1);
assert(yq0.year == 2020);
assert(yq0.month == Month.apr);

auto yq1 = yq0.add!"quarters"(1);
assert(yq1.year == 2020);
assert(yq1.month == Month.jul);

// also changes yq0
assert(yq0.year == 2020);
assert(yq0.month == Month.jul);

yq1.add!"quarters"(2);
assert(yq1.year == 2021);
assert(yq1.month == Month.jan);

yq1.add!"quarters"(-5);
assert(yq1.year == 2019);
assert(yq1.month == Month.oct);

Meta