index.js 624 B

1234567891011121314
  1. import toInteger from "../toInteger/index.js";
  2. import toDate from "../../toDate/index.js";
  3. import getUTCISOWeek from "../getUTCISOWeek/index.js";
  4. import requiredArgs from "../requiredArgs/index.js"; // This function will be a part of public API when UTC function will be implemented.
  5. // See issue: https://github.com/date-fns/date-fns/issues/376
  6. export default function setUTCISOWeek(dirtyDate, dirtyISOWeek) {
  7. requiredArgs(2, arguments);
  8. var date = toDate(dirtyDate);
  9. var isoWeek = toInteger(dirtyISOWeek);
  10. var diff = getUTCISOWeek(date) - isoWeek;
  11. date.setUTCDate(date.getUTCDate() - diff * 7);
  12. return date;
  13. }