UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

12 lines (11 loc) 321 B
import { setStartOfDay } from './index.js'; /** * Takes a given date and mutates it to the start of the given week */ export function setStartOfWeek(date) { const day = date.getDay(); const offset = day === 0 ? 6 : day - 1; date.setDate(date.getDate() - offset); setStartOfDay(date); return date; }