index.js 530 B

12345678910111213141516171819202122
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Common Helpers
  4. * @summary Is the given date in the past?
  5. *
  6. * @description
  7. * Is the given date in the past?
  8. *
  9. * @param {Date|String|Number} date - the date to check
  10. * @returns {Boolean} the date is in the past
  11. *
  12. * @example
  13. * // If today is 6 October 2014, is 2 July 2014 in the past?
  14. * var result = isPast(new Date(2014, 6, 2))
  15. * //=> true
  16. */
  17. function isPast (dirtyDate) {
  18. return parse(dirtyDate).getTime() < new Date().getTime()
  19. }
  20. module.exports = isPast