Skip to content

addTime

addTime(value: string, units: Partial<Record<TimeDurationUnit, number>>, options?: { overflow?: Overflow; }): string
import { addTime } from "@northguild/gmt/plain/calculate";

Return a PlainTime ISO string with units added to value.

  • Validates value, units, and amount before performing the add.
  • Returns “” for invalid inputs. overflow (“constrain” (default) | “reject”) is accepted for API consistency with sibling add functions, but PlainTime arithmetic always wraps around the clock (e.g. 23:00 + 2 hours = 01:00) rather than producing an out-of-range value, so it has no observable effect here.
Parameter Type Description
value string ISO PlainTime string
units Partial&lt;Record&lt;TimeDurationUnit, number&gt;&gt; Partial<Record<TimeDurationUnit, number>> object specifying units to add

options

Option Type Default
overflow? Overflow

ISO PlainTime string after addition, or “” on invalid input

addTime("12:00:00", { hours: 1 }) // "13:00:00"
addTime("invalid", { hours: 1 }) // ""

plain/calculate/addTime.ts