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

Function getDaysInMonth

pkgs/core/src/getDaysInMonth/index.ts:28–39  ·  view source on GitHub ↗
(
  date: DateArg<Date> & {},
  options?: GetDaysInMonthOptions | undefined,
)

Source from the content-addressed store, hash-verified

26 * //=> 29
27 */
28export function getDaysInMonth(
29 date: DateArg<Date> & {},
30 options?: GetDaysInMonthOptions | undefined,
31): number {
32 const _date = toDate(date, options?.in);
33 const year = _date.getFullYear();
34 const monthIndex = _date.getMonth();
35 const lastDayOfMonth = constructFrom(_date, 0);
36 lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
37 lastDayOfMonth.setHours(0, 0, 0, 0);
38 return lastDayOfMonth.getDate();
39}

Callers 3

test.tsFile · 0.90
_testFunction · 0.90
setMonthFunction · 0.90

Calls 2

toDateFunction · 0.90
constructFromFunction · 0.90

Tested by

no test coverage detected