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

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]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The date to be changed
§
week: number
[src]
  • The week of the new date
§
options?: SetWeekOptions optional
[src]
  • An object with options

§Return Type

§
DateType
[src]

The new date with the local week set