isThisISOWeek.mjs 993 B

1234567891011121314151617181920212223242526272829303132
  1. import { constructNow } from "./constructNow.mjs";
  2. import { isSameISOWeek } from "./isSameISOWeek.mjs";
  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. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  15. *
  16. * @param date - The date to check
  17. *
  18. * @returns The date is in this ISO week
  19. *
  20. * @example
  21. * // If today is 25 September 2014, is 22 September 2014 in this ISO week?
  22. * const result = isThisISOWeek(new Date(2014, 8, 22))
  23. * //=> true
  24. */
  25. export function isThisISOWeek(date) {
  26. return isSameISOWeek(date, constructNow(date));
  27. }
  28. // Fallback for modularized imports:
  29. export default isThisISOWeek;