addMonths method

  1. @override
DateTime addMonths(
  1. DateTime date,
  2. int months
)
override

Returns the date - DateTime.month + months with the DateTime.day as the dueDay, clamped to the months length.

Implementation

@override
DateTime addMonths(DateTime date, int months) {
  if (months == 0) return date;
  if (months.isNegative) return addMonths(previous(date), months + 1);
  return addMonths(next(date), months - 1);
}