{"version":3,"sources":["../src/addMonth.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n months after the original one. Keep in mind if you\n * start with a date late in a given month you could get a date after the next\n * month.\n * @param [inputDate] - A date to increment or null to increment from the current time\n * @param [count] - The quantity to add.\n * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addMonth(inputDate?: MaybeDateInput, count = 1, dateOverflow = false) {\n  const d = date(inputDate)\n  const dayOfMonth = d.getDate()\n  // If overflowing is disallowed, set the date back to the first of the month\n  if (!dateOverflow) d.setDate(1)\n  d.setMonth(d.getMonth() + count)\n\n  // If overflowing is disallowed, we need to set the date back to the proper\n  // day or the last day of the month.\n  if (!dateOverflow) {\n    const daysInMonth = monthDays(d)\n    d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n  }\n  return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAWnB,SAAS,SAAS,WAA4B,QAAQ,GAAG,eAAe,OAAO;AACpF,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,aAAa,EAAE,QAAQ;AAE7B,MAAI,CAAC,aAAc,GAAE,QAAQ,CAAC;AAC9B,IAAE,SAAS,EAAE,SAAS,IAAI,KAAK;AAI/B,MAAI,CAAC,cAAc;AACjB,UAAM,cAAc,UAAU,CAAC;AAC/B,MAAE,QAAQ,cAAc,aAAa,cAAc,UAAU;AAAA,EAC/D;AACA,SAAO;AACT;","names":[]}