index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isAfter;
  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 isAfter
  11. * @category Common Helpers
  12. * @summary Is the first date after the second one?
  13. *
  14. * @description
  15. * Is the first date after the second one?
  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} date - the date that should be after the other one to return true
  22. * @param {Date|Number} dateToCompare - the date to compare with
  23. * @returns {Boolean} the first date is after the second date
  24. * @throws {TypeError} 2 arguments required
  25. *
  26. * @example
  27. * // Is 10 July 1989 after 11 February 1987?
  28. * var result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
  29. * //=> true
  30. */
  31. function isAfter(dirtyDate, dirtyDateToCompare) {
  32. (0, _index2.default)(2, arguments);
  33. var date = (0, _index.default)(dirtyDate);
  34. var dateToCompare = (0, _index.default)(dirtyDateToCompare);
  35. return date.getTime() > dateToCompare.getTime();
  36. }
  37. module.exports = exports.default;