isThisHour.js 894 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. exports.isThisHour = isThisHour;
  3. var _index = require("./constructNow.js");
  4. var _index2 = require("./isSameHour.js");
  5. /**
  6. * @name isThisHour
  7. * @category Hour Helpers
  8. * @summary Is the given date in the same hour as the current date?
  9. * @pure false
  10. *
  11. * @description
  12. * Is the given date in the same hour as the current date?
  13. *
  14. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  15. *
  16. * @param date - The date to check
  17. *
  18. * @returns The date is in this hour
  19. *
  20. * @example
  21. * // If now is 25 September 2014 18:30:15.500,
  22. * // is 25 September 2014 18:00:00 in this hour?
  23. * const result = isThisHour(new Date(2014, 8, 25, 18))
  24. * //=> true
  25. */
  26. function isThisHour(date) {
  27. return (0, _index2.isSameHour)(date, (0, _index.constructNow)(date));
  28. }