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

Function startOfQuarter

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

Source from the content-addressed store, hash-verified

31 * //=> Tue Jul 01 2014 00:00:00
32 */
33export function startOfQuarter<
34 DateType extends Date,
35 ResultDate extends Date = DateType,
36>(
37 date: DateArg<DateType>,
38 options?: StartOfQuarterOptions<ResultDate> | undefined,
39): ResultDate {
40 const _date = toDate(date, options?.in);
41 const currentMonth = _date.getMonth();
42 const month = currentMonth - (currentMonth % 3);
43 _date.setMonth(month, 1);
44 _date.setHours(0, 0, 0, 0);
45 return _date;
46}

Callers 3

test.tsFile · 0.90
eachQuarterOfIntervalFunction · 0.90
isSameQuarterFunction · 0.90

Calls 1

toDateFunction · 0.90

Tested by

no test coverage detected