index.js 748 B

123456789101112131415161718192021222324
  1. var addMilliseconds = require('../add_milliseconds/index.js')
  2. /**
  3. * @category Second Helpers
  4. * @summary Add the specified number of seconds to the given date.
  5. *
  6. * @description
  7. * Add the specified number of seconds to 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 added
  11. * @returns {Date} the new date with the seconds added
  12. *
  13. * @example
  14. * // Add 30 seconds to 10 July 2014 12:45:00:
  15. * var result = addSeconds(new Date(2014, 6, 10, 12, 45, 0), 30)
  16. * //=> Thu Jul 10 2014 12:45:30
  17. */
  18. function addSeconds (dirtyDate, dirtyAmount) {
  19. var amount = Number(dirtyAmount)
  20. return addMilliseconds(dirtyDate, amount * 1000)
  21. }
  22. module.exports = addSeconds