The OpenD Programming Language

YearMonth.addMonths

struct YearMonth
nothrow @safe pure nothrow @nogc
addMonths
(
long months
)

Examples

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

auto ym1 = ym0.addMonths(15);
assert(ym1.year == 2021);
assert(ym1.month == Month.apr);

auto ym2 = ym1.addMonths(-6);
assert(ym2.year == 2020);
assert(ym2.month == Month.oct);

auto ym3 = YearMonth(2020, Month.dec).addMonths(3);
assert(ym3.year == 2021);
assert(ym3.month == Month.mar);

// ym0 is left unchagned
assert(ym0.year == 2020);
assert(ym0.month == Month.jan);

Meta