addMinutes.js 959 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. exports.addMinutes = addMinutes;
  3. var _index = require("./addMilliseconds.js");
  4. var _index2 = require("./constants.js");
  5. /**
  6. * @name addMinutes
  7. * @category Minute Helpers
  8. * @summary Add the specified number of minutes to the given date.
  9. *
  10. * @description
  11. * Add the specified number of minutes to the given date.
  12. *
  13. * @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).
  14. *
  15. * @param date - The date to be changed
  16. * @param amount - The amount of minutes to be added.
  17. *
  18. * @returns The new date with the minutes added
  19. *
  20. * @example
  21. * // Add 30 minutes to 10 July 2014 12:00:00:
  22. * const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
  23. * //=> Thu Jul 10 2014 12:30:00
  24. */
  25. function addMinutes(date, amount) {
  26. return (0, _index.addMilliseconds)(
  27. date,
  28. amount * _index2.millisecondsInMinute,
  29. );
  30. }