auto x = YearMonth(2020, Month.mar); auto x1 = x + 1; assert(x1 == YearMonth(2020, Month.apr)); auto x2 = x + 2; assert(x2 == YearMonth(2020, Month.may)); auto x3 = x + 3; assert(x3 == YearMonth(2020, Month.jun));
auto ym = YearMonth(2020, Month.mar); ym += 2; assert(ym == YearMonth(2020, Month.may)); ym -= 1; assert(ym == YearMonth(2020, Month.apr));
Get a slice of YearMonths
import mir.ndslice.topology: iota; static immutable result1 = [YearMonth(2020, Month.mar), YearMonth(2020, Month.apr), YearMonth(2020, Month.may), YearMonth(2020, Month.jun)]; static immutable result2 = [YearMonth(2020, Month.mar), YearMonth(2020, Month.may), YearMonth(2020, Month.jul), YearMonth(2020, Month.sep)]; auto ym = YearMonth(2020, Month.mar); auto x = ym + 4.iota!uint; assert(x == result1); // every other month auto y = ym + iota!uint([4], 0, 2); assert(y == result2);