DateTime.roll

DateTime roll(string units)(long value, AllowDayOverflow allowOverflow = AllowDayOverflow.yes) if (units == "years" || units == "months") ref @safe pure nothrow @nogc

Adds the given number of years or months to this DateTime, mutating it. A negative number will subtract.

The difference between rolling and adding is that rolling does not affect larger units. Rolling a DateTime 12 months gets the exact same DateTime. However, the days can still be affected due to the differing number of days in each month.

Because there are no units larger than years, there is no difference between adding and rolling years.

Parameters

unitsThe type of units to add ("years" or "months").
valueThe number of months or years to add to this DateTime.
allowOverflowWhether the days should be allowed to overflow, causing the month to increment.

Returns

A reference to the DateTime (this).
DateTime roll(string units)(long value) if (units == "days") ref @safe pure nothrow @nogc

Adds the given number of units to this DateTime, mutating it. A negative number will subtract.

The difference between rolling and adding is that rolling does not affect larger units. For instance, rolling a DateTime one year's worth of days gets the exact same DateTime.

Accepted units are "days", "minutes", "hours", "minutes", and "seconds".

Parameters

unitsThe units to add.
valueThe number of units to add to this DateTime.

Returns

A reference to the DateTime (this).
DateTime roll(string units)(long value) if (units == "hours" || units == "minutes" || units == "seconds") ref @safe pure nothrow @nogc

ditto