add static method

DateTime add({
  1. required DateTime date,
  2. required AgeDuration duration,
})

add method

Implementation

static DateTime add({required DateTime date, required AgeDuration duration}) {
  int years = date.year + duration.years;
  years += (date.month + duration.months) ~/ DateTime.monthsPerYear;

  int months = ((date.month + duration.months) % DateTime.monthsPerYear);

  int days = date.day + duration.days - 1;

  return DateTime(years, months, 1).add(Duration(days: days));
}