Gregorian.addMonths

Overridden. Returns a new Time with the specified number of months added. If the months are negative, the months are subtracted.

If the target month does not support the day component of the input time, then an error will be thrown, unless truncateDay is set to true. If truncateDay is set to true, then the day is reduced to the maximum day of that month.

For example, adding one month to 1/31/2000 with truncateDay set to true results in 2/28/2000.

class Gregorian
override
Time
addMonths
(
Time t
,,
bool truncateDay = false
)

Parameters

nMonths int

The number of months to add. This can be negative.

truncateDay bool

Round the day down to the maximum day of the target month if necessary.

Return Value

Type: Time

A Time that represents the provided time with the number of months added.

Meta