"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const constructFrom = require("./constructFrom.cjs");
const toDate = require("./toDate.cjs");
function addMonths(date, amount, options) {
  const _date = toDate.toDate(date);
  if (isNaN(amount)) return constructFrom.constructFrom(date, NaN);
  if (!amount) {
    return _date;
  }
  const dayOfMonth = _date.getDate();
  const endOfDesiredMonth = constructFrom.constructFrom(date, _date.getTime());
  endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
  const daysInMonth = endOfDesiredMonth.getDate();
  if (dayOfMonth >= daysInMonth) {
    return endOfDesiredMonth;
  } else {
    _date.setFullYear(
      endOfDesiredMonth.getFullYear(),
      endOfDesiredMonth.getMonth(),
      dayOfMonth
    );
    return _date;
  }
}
exports.addMonths = addMonths;
exports.default = addMonths;
//# sourceMappingURL=addMonths.cjs.map
