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

Function getISOWeek

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

Source from the content-addressed store, hash-verified

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

Callers 4

index.tsFile · 0.90
test.tsFile · 0.90
_testFunction · 0.90
setISOWeekFunction · 0.90

Calls 3

toDateFunction · 0.90
startOfISOWeekFunction · 0.90
startOfISOWeekYearFunction · 0.90

Tested by

no test coverage detected