addMonths method
Returns the date - DateTime.month + months with the week
occurrence of the day.
Implementation
@override
DateTime addMonths(DateTime date, int months) {
if (months == 0) return startDate(date);
var localMonths = months;
var localDate = startDate(date);
if (localMonths.isNegative) {
while (localMonths < 0) {
localDate = previous(localDate);
localMonths++;
}
} else {
while (localMonths > 0) {
localDate = next(localDate);
localMonths--;
}
}
return localDate;
}