index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import isSameWeek from "../isSameWeek/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.js";
  3. /**
  4. * @name isSameISOWeek
  5. * @category ISO Week Helpers
  6. * @summary Are the given dates in the same ISO week (and year)?
  7. *
  8. * @description
  9. * Are the given dates in the same ISO week (and year)?
  10. *
  11. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  12. *
  13. * @param {Date|Number} dateLeft - the first date to check
  14. * @param {Date|Number} dateRight - the second date to check
  15. * @returns {Boolean} the dates are in the same ISO week (and year)
  16. * @throws {TypeError} 2 arguments required
  17. *
  18. * @example
  19. * // Are 1 September 2014 and 7 September 2014 in the same ISO week?
  20. * const result = isSameISOWeek(new Date(2014, 8, 1), new Date(2014, 8, 7))
  21. * //=> true
  22. *
  23. * @example
  24. * // Are 1 September 2014 and 1 September 2015 in the same ISO week?
  25. * const result = isSameISOWeek(new Date(2014, 8, 1), new Date(2015, 8, 1))
  26. * //=> false
  27. */
  28. export default function isSameISOWeek(dirtyDateLeft, dirtyDateRight) {
  29. requiredArgs(2, arguments);
  30. return isSameWeek(dirtyDateLeft, dirtyDateRight, {
  31. weekStartsOn: 1
  32. });
  33. }