index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isThisHour;
  6. var _index = _interopRequireDefault(require("../isSameHour/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 isThisHour
  11. * @category Hour Helpers
  12. * @summary Is the given date in the same hour as the current date?
  13. * @pure false
  14. *
  15. * @description
  16. * Is the given date in the same hour as the current date?
  17. *
  18. * > ⚠️ Please note that this function is not present in the FP submodule as
  19. * > it uses `Date.now()` internally hence impure and can't be safely curried.
  20. *
  21. * ### v2.0.0 breaking changes:
  22. *
  23. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  24. *
  25. * @param {Date|Number} date - the date to check
  26. * @returns {Boolean} the date is in this hour
  27. * @throws {TypeError} 1 argument required
  28. *
  29. * @example
  30. * // If now is 25 September 2014 18:30:15.500,
  31. * // is 25 September 2014 18:00:00 in this hour?
  32. * var result = isThisHour(new Date(2014, 8, 25, 18))
  33. * //=> true
  34. */
  35. function isThisHour(dirtyDate) {
  36. (0, _index2.default)(1, arguments);
  37. return (0, _index.default)(Date.now(), dirtyDate);
  38. }
  39. module.exports = exports.default;