Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

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,
): DateType;
§
setWeekYear<DateType extends Date>(date: DateType | number | string, weekYear: number, options?: SetWeekYearOptions): DateType
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The date to be changed
§
weekYear: number
[src]
  • The local week-numbering year of the new date
§
options?: SetWeekYearOptions optional
[src]
  • An object with options

§Return Type

§
DateType
[src]

The new date with the local week-numbering year set