index.js 710 B

1234567891011121314151617181920212223242526
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Minute Helpers
  4. * @summary Set the minutes to the given date.
  5. *
  6. * @description
  7. * Set the minutes to the given date.
  8. *
  9. * @param {Date|String|Number} date - the date to be changed
  10. * @param {Number} minutes - the minutes of the new date
  11. * @returns {Date} the new date with the minutes setted
  12. *
  13. * @example
  14. * // Set 45 minutes to 1 September 2014 11:30:40:
  15. * var result = setMinutes(new Date(2014, 8, 1, 11, 30, 40), 45)
  16. * //=> Mon Sep 01 2014 11:45:40
  17. */
  18. function setMinutes (dirtyDate, dirtyMinutes) {
  19. var date = parse(dirtyDate)
  20. var minutes = Number(dirtyMinutes)
  21. date.setMinutes(minutes)
  22. return date
  23. }
  24. module.exports = setMinutes