1 import type { WeekStartsOn } from './interface';
4 weekStartsOn: WeekStartsOn;
6 const startOfWeek = (date: Date, options?: Options) => {
7 const weekStartsOn = !options || typeof options.weekStartsOn === 'undefined' ? 0 : options.weekStartsOn;
9 const result = new Date(+date);
10 const day = result.getUTCDay();
11 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
13 result.setUTCDate(date.getUTCDate() - diff);
14 result.setUTCHours(0, 0, 0, 0);
18 export default startOfWeek;