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

isSameWeek

import { isSameWeek } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Are 31 August 2014 and 4 September 2014 in the same week?
const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4))
//=> true
@example
// If week starts with Monday,
// are 31 August 2014 and 4 September 2014 in the same week?
const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4), {
  weekStartsOn: 1
})
//=> false
@example
// Are 1 January 2014 and 1 January 2015 in the same week?
const result = isSameWeek(new Date(2014, 0, 1), new Date(2015, 0, 1))
//=> false
function isSameWeek<DateType extends Date>(
dateLeft: DateType | number | string,
dateRight: DateType | number | string,
): boolean;
§
isSameWeek<DateType extends Date>(dateLeft: DateType | number | string, dateRight: DateType | number | string, options?: IsSameWeekOptions): boolean
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
dateLeft: DateType | number | string
[src]
  • The first date to check
§
dateRight: DateType | number | string
[src]
  • The second date to check
§
options?: IsSameWeekOptions optional
[src]
  • An object with options

§Return Type

§
boolean
[src]

The dates are in the same week (and month and year)