index.js 1014 B

1234567891011121314151617181920212223242526272829
  1. import isSameISOWeek from "../isSameISOWeek/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.js";
  3. /**
  4. * @name isThisISOWeek
  5. * @category ISO Week Helpers
  6. * @summary Is the given date in the same ISO week as the current date?
  7. * @pure false
  8. *
  9. * @description
  10. * Is the given date in the same ISO week as the current date?
  11. *
  12. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  13. *
  14. * > ⚠️ Please note that this function is not present in the FP submodule as
  15. * > it uses `Date.now()` internally hence impure and can't be safely curried.
  16. *
  17. * @param {Date|Number} date - the date to check
  18. * @returns {Boolean} the date is in this ISO week
  19. * @throws {TypeError} 1 argument required
  20. *
  21. * @example
  22. * // If today is 25 September 2014, is 22 September 2014 in this ISO week?
  23. * const result = isThisISOWeek(new Date(2014, 8, 22))
  24. * //=> true
  25. */
  26. export default function isThisISOWeek(dirtyDate) {
  27. requiredArgs(1, arguments);
  28. return isSameISOWeek(dirtyDate, Date.now());
  29. }