import toDate from '../toDate/index' ; import differenceInCalendarISOWeekYears from '../differenceInCalendarISOWeekYears/index' ; import compareAsc from '../compareAsc/index' ; import subISOWeekYears from '../subISOWeekYears/index' ; import requiredArgs from '../_lib/requiredArgs/index' ; name category summary description param { Date | Number } dateLeft param { Date | Number } dateRight returns { Number } throws example export default function differenceInISOWeekYears ( dirtyDateLeft , dirtyDateRight ) { requiredArgs ( 2 , arguments ) ; let dateLeft = toDate ( dirtyDateLeft ) ; const dateRight = toDate ( dirtyDateRight ) ; const sign = compareAsc ( dateLeft , dateRight ) ; const difference = Math . abs ( differenceInCalendarISOWeekYears ( dateLeft , dateRight ) ) ; dateLeft = subISOWeekYears ( dateLeft , sign * difference ) ; const isLastISOWeekYearNotFull = Number ( compareAsc ( dateLeft , dateRight ) === - sign ) ; const result = sign * ( difference - isLastISOWeekYearNotFull ) ; return result === 0 ? 0 : result ; }