index.js 770 B

12345678910111213141516171819202122232425262728
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Common Helpers
  4. * @summary Are the given dates equal?
  5. *
  6. * @description
  7. * Are the given dates equal?
  8. *
  9. * @param {Date|String|Number} dateLeft - the first date to compare
  10. * @param {Date|String|Number} dateRight - the second date to compare
  11. * @returns {Boolean} the dates are equal
  12. *
  13. * @example
  14. * // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
  15. * var result = isEqual(
  16. * new Date(2014, 6, 2, 6, 30, 45, 0)
  17. * new Date(2014, 6, 2, 6, 30, 45, 500)
  18. * )
  19. * //=> false
  20. */
  21. function isEqual (dirtyLeftDate, dirtyRightDate) {
  22. var dateLeft = parse(dirtyLeftDate)
  23. var dateRight = parse(dirtyRightDate)
  24. return dateLeft.getTime() === dateRight.getTime()
  25. }
  26. module.exports = isEqual