(
date: DateArg<Date> & {},
options?: GetISOWeeksInYearOptions | undefined,
)
| 29 | * //=> 53 |
| 30 | */ |
| 31 | export function getISOWeeksInYear( |
| 32 | date: DateArg<Date> & {}, |
| 33 | options?: GetISOWeeksInYearOptions | undefined, |
| 34 | ): number { |
| 35 | const thisYear = startOfISOWeekYear(date, options); |
| 36 | const nextYear = startOfISOWeekYear(addWeeks(thisYear, 60)); |
| 37 | const diff = +nextYear - +thisYear; |
| 38 | |
| 39 | // Round the number of weeks to the nearest integer because the number of |
| 40 | // milliseconds in a week is not constant (e.g. it's different in the week of |
| 41 | // the daylight saving time clock shift). |
| 42 | return Math.round(diff / millisecondsInWeek); |
| 43 | } |
no test coverage detected