index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isSameMinute;
  6. var _index = _interopRequireDefault(require("../startOfMinute/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 isSameMinute
  11. * @category Minute Helpers
  12. * @summary Are the given dates in the same minute?
  13. *
  14. * @description
  15. * Are the given dates in the same minute?
  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 minute
  24. * @throws {TypeError} 2 arguments required
  25. *
  26. * @example
  27. * // Are 4 September 2014 06:30:00 and 4 September 2014 06:30:15
  28. * // in the same minute?
  29. * var result = isSameMinute(
  30. * new Date(2014, 8, 4, 6, 30),
  31. * new Date(2014, 8, 4, 6, 30, 15)
  32. * )
  33. * //=> true
  34. */
  35. function isSameMinute(dirtyDateLeft, dirtyDateRight) {
  36. (0, _index2.default)(2, arguments);
  37. var dateLeftStartOfMinute = (0, _index.default)(dirtyDateLeft);
  38. var dateRightStartOfMinute = (0, _index.default)(dirtyDateRight);
  39. return dateLeftStartOfMinute.getTime() === dateRightStartOfMinute.getTime();
  40. }
  41. module.exports = exports.default;