index.js 618 B

1234567891011121314
  1. import toInteger from "../toInteger/index.js";
  2. import toDate from "../../toDate/index.js";
  3. import getUTCWeek from "../getUTCWeek/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 setUTCWeek(dirtyDate, dirtyWeek, options) {
  7. requiredArgs(2, arguments);
  8. var date = toDate(dirtyDate);
  9. var week = toInteger(dirtyWeek);
  10. var diff = getUTCWeek(date, options) - week;
  11. date.setUTCDate(date.getUTCDate() - diff * 7);
  12. return date;
  13. }