import startOfWeek from '../startOfWeek/index' ; import startOfWeekYear from '../startOfWeekYear/index' ; import toDate from '../toDate/index' ; import requiredArgs from '../_lib/requiredArgs/index' ; import type { LocaleOptions , WeekStartOptions , FirstWeekContainsDateOptions , } from '../types' ; const MILLISECONDS_IN_WEEK = 604800000 ; name category summary description param { Date | Number } date param options param { Locale } options . locale - the locale object. See [Locale] https param { 0 | 1 | 2 | 3 | 4 | 5 | 6 } options . weekStartsOn param { 1 | 2 | 3 | 4 | 5 | 6 | 7 } options . firstWeekContainsDate returns { Number } throws throws throws example export default function getWeek ( dirtyDate , options ? ) { requiredArgs ( 1 , arguments ) ; const date = toDate ( dirtyDate ) ; const diff = startOfWeek ( date , options ) . getTime ( ) - startOfWeekYear ( date , options ) . getTime ( ) ; return Math . round ( diff / MILLISECONDS_IN_WEEK ) + 1 ; }