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

Function getWeek

pkgs/core/src/getWeek/index.ts:57–68  ·  view source on GitHub ↗
(
  date: DateArg<Date> & {},
  options?: GetWeekOptions | undefined,
)

Source from the content-addressed store, hash-verified

55 * //=> 53
56 */
57export function getWeek(
58 date: DateArg<Date> & {},
59 options?: GetWeekOptions | undefined,
60): number {
61 const _date = toDate(date, options?.in);
62 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
63
64 // Round the number of weeks to the nearest integer because the number of
65 // milliseconds in a week is not constant (e.g. it's different in the week of
66 // the daylight saving time clock shift).
67 return Math.round(diff / millisecondsInWeek) + 1;
68}

Callers 5

test.tsFile · 0.90
_testFunction · 0.90
index.tsFile · 0.90
test.tsFile · 0.90
setWeekFunction · 0.90

Calls 3

toDateFunction · 0.90
startOfWeekFunction · 0.90
startOfWeekYearFunction · 0.90

Tested by

no test coverage detected