subtractMonths method

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

Subtracts the specified number of months from the current DateTime.

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

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

Implementation

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

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