index.js 727 B

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