addMinutes.mjs 977 B

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