(
date: DateArg<Date> & {},
options?: GetISOWeekOptions | undefined,
)
| 30 | * //=> 53 |
| 31 | */ |
| 32 | export function getISOWeek( |
| 33 | date: DateArg<Date> & {}, |
| 34 | options?: GetISOWeekOptions | undefined, |
| 35 | ): number { |
| 36 | const _date = toDate(date, options?.in); |
| 37 | const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); |
| 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) + 1; |
| 43 | } |
no test coverage detected