setWeek
import { setWeek } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Set the 1st week to 2 January 2005 with default options:
const result = setWeek(new Date(2005, 0, 2), 1)
//=> Sun Dec 26 2004 00:00:00
@example
// Set the 1st week to 2 January 2005,
// if Monday is the first day of the week,
// and the first week of the year always contains 4 January:
const result = setWeek(new Date(2005, 0, 2), 1, {
weekStartsOn: 1,
firstWeekContainsDate: 4
})
//=> Sun Jan 4 2004 00:00:00
function setWeek<DateType extends Date>(
date: DateType | number | string,
week: number,
options?: SetWeekOptions,
): DateType;§
setWeek<DateType extends Date>(date: DateType | number | string, week: number, options?: SetWeekOptions): DateType
[src]§Parameters
§
options?: SetWeekOptions optional
[src]- An object with options