index.js 798 B

1234567891011121314151617181920212223242526
  1. var addMilliseconds = require('../add_milliseconds/index.js')
  2. var MILLISECONDS_IN_MINUTE = 60000
  3. /**
  4. * @category Minute Helpers
  5. * @summary Add the specified number of minutes to the given date.
  6. *
  7. * @description
  8. * Add the specified number of minutes to the given date.
  9. *
  10. * @param {Date|String|Number} date - the date to be changed
  11. * @param {Number} amount - the amount of minutes to be added
  12. * @returns {Date} the new date with the minutes added
  13. *
  14. * @example
  15. * // Add 30 minutes to 10 July 2014 12:00:00:
  16. * var result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
  17. * //=> Thu Jul 10 2014 12:30:00
  18. */
  19. function addMinutes (dirtyDate, dirtyAmount) {
  20. var amount = Number(dirtyAmount)
  21. return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_MINUTE)
  22. }
  23. module.exports = addMinutes