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

Function addDays

pkgs/core/src/addDays/index.ts:53–69  ·  view source on GitHub ↗
(
  date: DateArg<DateType>,
  amount: number,
  options?: AddDaysOptions<ResultDate> | undefined,
)

Source from the content-addressed store, hash-verified

51 * //=> "2014-09-11"
52 */
53export function addDays<
54 DateType extends Date,
55 ResultDate extends Date = DateType,
56>(
57 date: DateArg<DateType>,
58 amount: number,
59 options?: AddDaysOptions<ResultDate> | undefined,
60): ResultDate {
61 const _date = toDate(date, options?.in);
62 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
63
64 // If 0 days, no-op to avoid changing times in the hour before end of DST
65 if (!amount) return _date;
66
67 _date.setDate(_date.getDate() + amount);
68 return _date;
69}

Callers 10

test.tsFile · 0.90
differenceInBusinessDaysFunction · 0.90
addWeeksFunction · 0.90
isTomorrowFunction · 0.90
nextDayFunction · 0.90
test.tsFile · 0.90
setISODayFunction · 0.90
addFunction · 0.90
subDaysFunction · 0.90
setDayFunction · 0.90

Calls 2

toDateFunction · 0.90
constructFromFunction · 0.90

Tested by

no test coverage detected