index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import isSameSecond from "../isSameSecond/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.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. * > ⚠️ Please note that this function is not present in the FP submodule as
  13. * > it uses `Date.now()` internally hence impure and can't be safely curried.
  14. *
  15. * ### v2.0.0 breaking changes:
  16. *
  17. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  18. *
  19. * @param {Date|Number} date - the date to check
  20. * @returns {Boolean} the date is in this second
  21. * @throws {TypeError} 1 argument required
  22. *
  23. * @example
  24. * // If now is 25 September 2014 18:30:15.500,
  25. * // is 25 September 2014 18:30:15.000 in this second?
  26. * var result = isThisSecond(new Date(2014, 8, 25, 18, 30, 15))
  27. * //=> true
  28. */
  29. export default function isThisSecond(dirtyDate) {
  30. requiredArgs(1, arguments);
  31. return isSameSecond(Date.now(), dirtyDate);
  32. }