MCPcopy
hub / github.com/date-fns/date-fns / getISOWeeksInYear

Function getISOWeeksInYear

pkgs/core/src/getISOWeeksInYear/index.ts:31–43  ·  view source on GitHub ↗
(
  date: DateArg<Date> & {},
  options?: GetISOWeeksInYearOptions | undefined,
)

Source from the content-addressed store, hash-verified

29 * //=> 53
30 */
31export 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}

Callers 2

test.tsFile · 0.90
_testFunction · 0.90

Calls 2

startOfISOWeekYearFunction · 0.90
addWeeksFunction · 0.90

Tested by

no test coverage detected