index.js 777 B

12345678910111213141516171819202122232425
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Common Helpers
  4. * @summary Is the first date after the second one?
  5. *
  6. * @description
  7. * Is the first date after the second one?
  8. *
  9. * @param {Date|String|Number} date - the date that should be after the other one to return true
  10. * @param {Date|String|Number} dateToCompare - the date to compare with
  11. * @returns {Boolean} the first date is after the second date
  12. *
  13. * @example
  14. * // Is 10 July 1989 after 11 February 1987?
  15. * var result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
  16. * //=> true
  17. */
  18. function isAfter (dirtyDate, dirtyDateToCompare) {
  19. var date = parse(dirtyDate)
  20. var dateToCompare = parse(dirtyDateToCompare)
  21. return date.getTime() > dateToCompare.getTime()
  22. }
  23. module.exports = isAfter