clampZoned
Signature
Section titled “Signature”clampZoned(value: string, min: string, max: string): stringRestrict value to the range [min, max] in zoned datetime space.
- Returns
valueif it falls within the bounds (inclusive on both ends). - Returns
minifvalueis beforemin. - Returns
maxifvalueis aftermax. - Returns
""if any input is invalid ormin > max.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO ZonedDateTime string to clamp |
min | string | ISO ZonedDateTime string for the lower bound (inclusive) |
max | string | ISO ZonedDateTime string for the upper bound (inclusive) |
Returns
Section titled “Returns”The clamped zoned datetime string, or "" on invalid input
Examples
Section titled “Examples”import { clampZoned } from "@northguild/gmt/zoned/calculate";
clampZoned("2024-03-15T12:00:00+00:00[UTC]", "2024-03-01T00:00:00+00:00[UTC]", "2024-03-31T23:59:59+00:00[UTC]") // "2024-03-15T12:00:00+00:00[UTC]"