import startOfWeek from '../startOfWeek/index' ; import getTimezoneOffsetInMilliseconds from '../_lib/getTimezoneOffsetInMilliseconds/index' ; import requiredArgs from '../_lib/requiredArgs/index' ; import type { LocaleOptions , WeekStartOptions } from '../types' ; const MILLISECONDS_IN_WEEK = 604800000 ; name category summary description param { Date | Number } dateLeft param { Date | Number } dateRight param options param { Locale } options . locale - the locale object. See [Locale] https param { 0 | 1 | 2 | 3 | 4 | 5 | 6 } options . weekStartsOn returns { Number } throws throws example example export default function differenceInCalendarWeeks ( dirtyDateLeft , dirtyDateRight , dirtyOptions ? ) { requiredArgs ( 2 , arguments ) ; const startOfWeekLeft = startOfWeek ( dirtyDateLeft , dirtyOptions ) ; const startOfWeekRight = startOfWeek ( dirtyDateRight , dirtyOptions ) ; const timestampLeft = startOfWeekLeft . getTime ( ) - getTimezoneOffsetInMilliseconds ( startOfWeekLeft ) ; const timestampRight = startOfWeekRight . getTime ( ) - getTimezoneOffsetInMilliseconds ( startOfWeekRight ) ; return Math . round ( ( timestampLeft - timestampRight ) / MILLISECONDS_IN_WEEK ) ; }