index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isSameQuarter;
  6. var _index = _interopRequireDefault(require("../startOfQuarter/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 isSameQuarter
  11. * @category Quarter Helpers
  12. * @summary Are the given dates in the same year quarter?
  13. *
  14. * @description
  15. * Are the given dates in the same year quarter?
  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 check
  22. * @param {Date|Number} dateRight - the second date to check
  23. * @returns {Boolean} the dates are in the same quarter
  24. * @throws {TypeError} 2 arguments required
  25. *
  26. * @example
  27. * // Are 1 January 2014 and 8 March 2014 in the same quarter?
  28. * var result = isSameQuarter(new Date(2014, 0, 1), new Date(2014, 2, 8))
  29. * //=> true
  30. */
  31. function isSameQuarter(dirtyDateLeft, dirtyDateRight) {
  32. (0, _index2.default)(2, arguments);
  33. var dateLeftStartOfQuarter = (0, _index.default)(dirtyDateLeft);
  34. var dateRightStartOfQuarter = (0, _index.default)(dirtyDateRight);
  35. return dateLeftStartOfQuarter.getTime() === dateRightStartOfQuarter.getTime();
  36. }
  37. module.exports = exports.default;