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