subtractTime
Signature
Section titled “Signature”subtractTime(value: string, units: Partial<Record<TimeDurationUnit, number>>, options?: { overflow?: Overflow; }): stringimport { subtractTime } from "@northguild/gmt/plain/calculate";Return a PlainTime ISO string with units subtracted from value.
- Validates
value,units, andamountbefore performing the subtract. - Returns “” for invalid inputs.
overflow(“constrain” (default) | “reject”) is accepted for API consistency with sibling subtract functions, but PlainTime arithmetic always wraps around the clock (e.g. 01:00 - 2 hours = 23:00) rather than producing an out-of-range value, so it has no observable effect here.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
ISO PlainTime string |
units |
Partial<Record<TimeDurationUnit, number>> |
Partial<Record<TimeDurationUnit, number>> object specifying units to subtract |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
overflow? |
Overflow |
— |
Returns
Section titled “Returns”ISO PlainTime string after subtraction, or “” on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”subtractTime("14:30:00", { hours: 1 }) // "13:30:00"subtractTime("invalid", { hours: 1 }) // ""