isThisHour.cjs 918 B

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. exports.isThisHour = isThisHour;
  3. var _index = require("./constructNow.cjs");
  4. var _index2 = require("./isSameHour.cjs");
  5. var _index3 = require("./toDate.cjs");
  6. /**
  7. * The {@link isThisHour} function options.
  8. */
  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. * @param date - The date to check
  19. * @param options - An object with options
  20. *
  21. * @returns The date is in this hour
  22. *
  23. * @example
  24. * // If now is 25 September 2014 18:30:15.500,
  25. * // is 25 September 2014 18:00:00 in this hour?
  26. * const result = isThisHour(new Date(2014, 8, 25, 18))
  27. * //=> true
  28. */
  29. function isThisHour(date, options) {
  30. return (0, _index2.isSameHour)(
  31. (0, _index3.toDate)(date, options?.in),
  32. (0, _index.constructNow)(options?.in || date),
  33. );
  34. }