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

Function tpyAdd

pkgs/core/src/add/index.tp.ts:5–27  ·  view source on GitHub ↗
(
  date: DateArg<DateType>,
  duration: Duration,
  options?: AddOptions<ResultDate> | undefined,
)

Source from the content-addressed store, hash-verified

3import type { AddOptions } from "./index.ts";
4
5export function tpyAdd<
6 DateType extends Date,
7 ResultDate extends Date = DateType,
8>(
9 date: DateArg<DateType>,
10 duration: Duration,
11 options?: AddOptions<ResultDate> | undefined,
12): ResultDate {
13 let [temporal, invalidDate] = toTpInstant(date, options);
14 if (!temporal) return invalidDate;
15
16 const result = temporal.add({
17 years: duration.years ?? 0,
18 months: duration.months ?? 0,
19 weeks: duration.weeks ?? 0,
20 days: duration.days ?? 0,
21 hours: duration.hours ?? 0,
22 minutes: duration.minutes ?? 0,
23 seconds: duration.seconds ?? 0,
24 });
25
26 return fromTp(result, date, options);
27}

Callers

nothing calls this directly

Calls 2

toTpInstantFunction · 0.90
fromTpFunction · 0.90

Tested by

no test coverage detected