isThisSecond.js 757 B

12345678910111213141516171819202122232425262728
  1. import { constructNow } from "./constructNow.js";
  2. import { isSameSecond } from "./isSameSecond.js";
  3. /**
  4. * @name isThisSecond
  5. * @category Second Helpers
  6. * @summary Is the given date in the same second as the current date?
  7. * @pure false
  8. *
  9. * @description
  10. * Is the given date in the same second as the current date?
  11. *
  12. * @param date - The date to check
  13. *
  14. * @returns The date is in this second
  15. *
  16. * @example
  17. * // If now is 25 September 2014 18:30:15.500,
  18. * // is 25 September 2014 18:30:15.000 in this second?
  19. * const result = isThisSecond(new Date(2014, 8, 25, 18, 30, 15))
  20. * //=> true
  21. */
  22. export function isThisSecond(date) {
  23. return isSameSecond(date, constructNow(date));
  24. }
  25. // Fallback for modularized imports:
  26. export default isThisSecond;