index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isEqual;
  6. var _index = _interopRequireDefault(require("../toDate/index.js"));
  7. var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * @name isEqual
  11. * @category Common Helpers
  12. * @summary Are the given dates equal?
  13. *
  14. * @description
  15. * Are the given dates equal?
  16. *
  17. * ### v2.0.0 breaking changes:
  18. *
  19. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  20. *
  21. * @param {Date|Number} dateLeft - the first date to compare
  22. * @param {Date|Number} dateRight - the second date to compare
  23. * @returns {Boolean} the dates are equal
  24. * @throws {TypeError} 2 arguments required
  25. *
  26. * @example
  27. * // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
  28. * var result = isEqual(
  29. * new Date(2014, 6, 2, 6, 30, 45, 0),
  30. * new Date(2014, 6, 2, 6, 30, 45, 500)
  31. * )
  32. * //=> false
  33. */
  34. function isEqual(dirtyLeftDate, dirtyRightDate) {
  35. (0, _index2.default)(2, arguments);
  36. var dateLeft = (0, _index.default)(dirtyLeftDate);
  37. var dateRight = (0, _index.default)(dirtyRightDate);
  38. return dateLeft.getTime() === dateRight.getTime();
  39. }
  40. module.exports = exports.default;