addMonths method

  1. @useResult
DateTime addMonths(
  1. int months
)

Adds the specified number of months to the current DateTime.

Args: months (int): The number of months to add.

Returns: DateTime: A new DateTime object with the added months.

Implementation

@useResult
DateTime addMonths(int months) {
  if (months == 0) {
    return this;
  }

  return Jiffy.parseFromDateTime(this).add(months: months).dateTime;
}