subHours.js 867 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. exports.subHours = subHours;
  3. var _index = require("./addHours.js");
  4. /**
  5. * @name subHours
  6. * @category Hour Helpers
  7. * @summary Subtract the specified number of hours from the given date.
  8. *
  9. * @description
  10. * Subtract the specified number of hours from the given date.
  11. *
  12. * @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).
  13. *
  14. * @param date - The date to be changed
  15. * @param amount - The amount of hours to be subtracted.
  16. *
  17. * @returns The new date with the hours subtracted
  18. *
  19. * @example
  20. * // Subtract 2 hours from 11 July 2014 01:00:00:
  21. * const result = subHours(new Date(2014, 6, 11, 1, 0), 2)
  22. * //=> Thu Jul 10 2014 23:00:00
  23. */
  24. function subHours(date, amount) {
  25. return (0, _index.addHours)(date, -amount);
  26. }