# plusMonths method

LocalDate plusMonths(

1. int months

)

Returns a new LocalDate with `months` added.

Example:

    final date = LocalDate(2023, 1, 31);
    final result = date.plusMonths(1); // 2023-02-28

## Implementation

    LocalDate plusMonths(int months) {
      int newYear = year;
      int newMonth = month + months;
      while (newMonth > 12) {
        newMonth -= 12;
        newYear++;
      }
      while (newMonth < 1) {
        newMonth += 12;
        newYear--;
      }
      int newDay = day;
      final maxDay = _daysInMonth(newYear, newMonth);
      if (newDay > maxDay) {
        newDay = maxDay;
      }
      return LocalDate(newYear, newMonth, newDay);
    }