UNPKG

@technobuddha/library

Version:
17 lines (16 loc) 644 B
import { day } from '../constants'; import getBeginningOfWeek from '../getBeginningOfWeek'; /** * Determine if two dates occur in the same week * * @param input1 The first date * @param input2 The second date * @param __namedParameters see {@link Options} * @default UTC false * @default firstDayOfWeek Sunday * @returns true, if the two dates occur in the same week */ export function isSameWeek(input1, input2, { UTC = false, firstDayOfWeek = day.sunday } = {}) { return getBeginningOfWeek(input1, { UTC, firstDayOfWeek }).getTime() === getBeginningOfWeek(input2, { UTC, firstDayOfWeek }).getTime(); } export default isSameWeek;