import getWeekYear from '../getWeekYear/index' ; import startOfWeek from '../startOfWeek/index' ; import toInteger from '../_lib/toInteger/index' ; import requiredArgs from '../_lib/requiredArgs/index' ; import type { LocaleOptions , FirstWeekContainsDateOptions , WeekStartOptions , } from '../types' ; 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 { Date } throws throws throws example example export default function startOfWeekYear ( dirtyDate , dirtyOptions ? ) { requiredArgs ( 1 , arguments ) ; const options = dirtyOptions || { } ; const locale = options . locale ; const localeFirstWeekContainsDate = locale && locale . options && locale . options . firstWeekContainsDate ; const defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger ( localeFirstWeekContainsDate ) ; const firstWeekContainsDate = options . firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger ( options . firstWeekContainsDate ) ; const year = getWeekYear ( dirtyDate , dirtyOptions ) ; const firstWeek = new Date ( 0 ) ; firstWeek . setFullYear ( year , 0 , firstWeekContainsDate ) ; firstWeek . setHours ( 0 , 0 , 0 , 0 ) ; const date = startOfWeek ( firstWeek , dirtyOptions ) ; return date ; }