subSeconds.js 900 B

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