subMinutes.mjs 915 B

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