index.js 758 B

123456789101112131415161718192021222324
  1. var addSeconds = require('../add_seconds/index.js')
  2. /**
  3. * @category Second Helpers
  4. * @summary Subtract the specified number of seconds from the given date.
  5. *
  6. * @description
  7. * Subtract the specified number of seconds from the given date.
  8. *
  9. * @param {Date|String|Number} date - the date to be changed
  10. * @param {Number} amount - the amount of seconds to be subtracted
  11. * @returns {Date} the new date with the seconds subtracted
  12. *
  13. * @example
  14. * // Subtract 30 seconds from 10 July 2014 12:45:00:
  15. * var result = subSeconds(new Date(2014, 6, 10, 12, 45, 0), 30)
  16. * //=> Thu Jul 10 2014 12:44:30
  17. */
  18. function subSeconds (dirtyDate, dirtyAmount) {
  19. var amount = Number(dirtyAmount)
  20. return addSeconds(dirtyDate, -amount)
  21. }
  22. module.exports = subSeconds