jobiqo-cl
Version:
[](https://circleci.com/gh/jobiqo/jobiqo-cl)
20 lines (15 loc) • 601 B
JavaScript
import toDate from '../../toDate/index.js';
import toInteger from '../toInteger/index.js';
import getUTCISOWeek from '../getUTCISOWeek/index.js';
// See issue: https://github.com/date-fns/date-fns/issues/376
function setUTCISOWeek(dirtyDate, dirtyISOWeek) {
if (arguments.length < 2) {
throw new TypeError('2 arguments required, but only ' + arguments.length + ' present');
}
var date = toDate(dirtyDate);
var isoWeek = toInteger(dirtyISOWeek);
var diff = getUTCISOWeek(date) - isoWeek;
date.setUTCDate(date.getUTCDate() - diff * 7);
return date;
}
export default setUTCISOWeek;