addMonths.d.mts 922 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @name addMonths
  3. * @category Month Helpers
  4. * @summary Add the specified number of months to the given date.
  5. *
  6. * @description
  7. * Add the specified number of months to the given date.
  8. *
  9. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  10. *
  11. * @param date - The date to be changed
  12. * @param amount - The amount of months to be added.
  13. *
  14. * @returns The new date with the months added
  15. *
  16. * @example
  17. * // Add 5 months to 1 September 2014:
  18. * const result = addMonths(new Date(2014, 8, 1), 5)
  19. * //=> Sun Feb 01 2015 00:00:00
  20. *
  21. * // Add one month to 30 January 2023:
  22. * const result = addMonths(new Date(2023, 0, 30), 1)
  23. * //=> Tue Feb 28 2023 00:00:00
  24. */
  25. export declare function addMonths<DateType extends Date>(
  26. date: DateType | number | string,
  27. amount: number,
  28. ): DateType;