auto d = Date(2020, 1, 1); d += 2; assert(d == Date(2020, 1, 3)); d -= 1; assert(d == Date(2020, 1, 2));
Get a slice of Dates
import mir.ndslice.topology: iota, map; static immutable result1 = [Date(2020, Month.mar, 1), Date(2020, Month.mar, 2), Date(2020, Month.mar, 3), Date(2020, Month.mar, 4)]; static immutable result2 = [Date(2020, Month.mar, 1), Date(2020, Month.mar, 3), Date(2020, Month.mar, 5), Date(2020, Month.mar, 7)]; static immutable result3 = [Date(2020, Month.mar, 1), Date(2020, Month.apr, 1), Date(2020, Month.may, 1), Date(2020, Month.jun, 1)]; static immutable result4 = [Date(2020, Month.mar, 1), Date(2020, Month.jun, 1), Date(2020, Month.sep, 1), Date(2020, Month.dec, 1)]; static immutable result5 = [Date(2020, Month.mar, 1), Date(2021, Month.mar, 1), Date(2022, Month.mar, 1), Date(2023, Month.mar, 1)]; auto d = Date(2020, Month.mar, 1); auto x = d + 4.iota!uint; assert(x == result1); // every other date auto y = d + iota!uint([4], 0, 2); assert(y == result2); // every month auto z = (d.YearMonth + 4.iota!uint).map!Date; assert(z == result3); // every quarter auto a = (d.YearQuarter + 4.iota!uint).map!(a => a.Date(AssumePeriod.end, AssumePeriod.begin)); assert(a == result4); // every year auto b = (d.year + 4.iota!uint).map!(a => YearMonthDay(cast(short) a, Month.mar, 1).Date); assert(b == result5);