index.js 573 B

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