index.js 754 B

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