nextMonth function

DateTime nextMonth(
  1. DateTime date
)

Implementation

DateTime nextMonth(DateTime date) {
  int y = date.year;
  int m = date.month;
  int d = date.day;

  if (m == 12) {
    y = y + 1;
    m = 1;
  } else {
    m = m + 1;
  }

  if (d > getMonthDays(y, m)) {
    d = getMonthDays(y, m);
  }

  return intToDate(y, m, d, h: date.hour, min: date.minute);
}