index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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. * ### v2.0.0 breaking changes:
  18. *
  19. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  20. *
  21. * @param {Date|Number} date - the date to check
  22. * @returns {Boolean} the date is in this ISO week
  23. * @throws {TypeError} 1 argument required
  24. *
  25. * @example
  26. * // If today is 25 September 2014, is 22 September 2014 in this ISO week?
  27. * var result = isThisISOWeek(new Date(2014, 8, 22))
  28. * //=> true
  29. */
  30. export default function isThisISOWeek(dirtyDate) {
  31. requiredArgs(1, arguments);
  32. return isSameISOWeek(dirtyDate, Date.now());
  33. }