addDateTime
Signature
Section titled “Signature”addDateTime(value: string, units: Partial<Record<keyof DurationLike, number>>, options?: { overflow?: "reject" | "constrain" | undefined; }): stringReturn a PlainDateTime ISO string with units added to value.
- Validates
value,units, andamountbefore performing the add. - Returns "" for invalid inputs.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO PlainDateTime string |
units | Partial<Record<keyof DurationLike, number>> | Partial<Record<DateTimeDurationUnit, number>> object specifying units to add |
Options
Section titled “Options”options
How an out-of-range result is handled
| Option | Type | Default | Description |
|---|---|---|---|
overflow? | "reject" | "constrain" (Overflow) | "constrain", Temporal’s default. | What to do when the result is not a real date. "constrain" clamps it to the last valid day, so Jan 31 + 1 month is Feb 29 or 28; "reject" returns "". |
Returns
Section titled “Returns”ISO PlainDateTime string after addition, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { addDateTime } from "@northguild/gmt/plain/calculate";
addDateTime("2024-03-10T12:00:00", { days: 5 }) // "2024-03-15T12:00:00"