The OpenD Programming Language

YearMonth.add

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

Examples

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

ym0.add!"years"(1);
assert(ym0.year == 2021);
assert(ym0.month == Month.jan);

auto ym1 = ym0.add!"years"(1);
assert(ym1.year == 2022);
assert(ym1.month == Month.jan);

// also changes ym0
assert(ym0.year == 2022);
assert(ym0.month == Month.jan);

Meta