isThisISOWeek.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { constructFrom } from "./constructFrom.js";
  2. import { constructNow } from "./constructNow.js";
  3. import { isSameISOWeek } from "./isSameISOWeek.js";
  4. /**
  5. * The {@link isThisISOWeek} function options.
  6. */
  7. /**
  8. * @name isThisISOWeek
  9. * @category ISO Week Helpers
  10. * @summary Is the given date in the same ISO week as the current date?
  11. * @pure false
  12. *
  13. * @description
  14. * Is the given date in the same ISO week as the current date?
  15. *
  16. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  17. *
  18. * @param date - The date to check
  19. * @param options - An object with options
  20. *
  21. * @returns The date is in this ISO week
  22. *
  23. * @example
  24. * // If today is 25 September 2014, is 22 September 2014 in this ISO week?
  25. * const result = isThisISOWeek(new Date(2014, 8, 22))
  26. * //=> true
  27. */
  28. export function isThisISOWeek(date, options) {
  29. return isSameISOWeek(
  30. constructFrom(options?.in || date, date),
  31. constructNow(options?.in || date),
  32. );
  33. }
  34. // Fallback for modularized imports:
  35. export default isThisISOWeek;