{"version":3,"sources":["../src/addYear.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n years after the original one. Keep in mind if\n * you start with a date late in a given month you could get a date after the\n * next month.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity of years 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 addYear(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\n  d.setFullYear(d.getFullYear() + 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,QAAQ,WAA4B,QAAQ,GAAG,eAAe,OAAO;AACnF,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,aAAa,EAAE,QAAQ;AAE7B,MAAI,CAAC,aAAc,GAAE,QAAQ,CAAC;AAE9B,IAAE,YAAY,EAAE,YAAY,IAAI,KAAK;AAIrC,MAAI,CAAC,cAAc;AACjB,UAAM,cAAc,UAAU,CAAC;AAC/B,MAAE,QAAQ,cAAc,aAAa,cAAc,UAAU;AAAA,EAC/D;AACA,SAAO;AACT;","names":[]}