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

Function endOfMonth

pkgs/core/src/endOfMonth/index.ts:33–45  ·  view source on GitHub ↗
(
  date: DateArg<DateType>,
  options?: EndOfMonthOptions<ResultDate> | undefined,
)

Source from the content-addressed store, hash-verified

31 * //=> Tue Sep 30 2014 23:59:59.999
32 */
33export function endOfMonth<
34 DateType extends Date,
35 ResultDate extends Date = DateType,
36>(
37 date: DateArg<DateType>,
38 options?: EndOfMonthOptions<ResultDate> | undefined,
39): ResultDate {
40 const _date = toDate(date, options?.in);
41 const month = _date.getMonth();
42 _date.setFullYear(_date.getFullYear(), month + 1, 0);
43 _date.setHours(23, 59, 59, 999);
44 return _date;
45}

Callers 3

isLastDayOfMonthFunction · 0.90
eachWeekendOfMonthFunction · 0.90
test.tsFile · 0.90

Calls 1

toDateFunction · 0.90

Tested by

no test coverage detected