@qntm-code/utils
Version:
A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.
16 lines (15 loc) • 479 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.setStartOfWeek = void 0;
const index_js_1 = require("./index.js");
/**
* Takes a given date and mutates it to the start of the given week
*/
function setStartOfWeek(date) {
const day = date.getDay();
const offset = day === 0 ? 6 : day - 1;
date.setDate(date.getDate() - offset);
(0, index_js_1.setStartOfDay)(date);
return date;
}
exports.setStartOfWeek = setStartOfWeek;