# clampZoned

Industry: Core

## Signature

```ts
clampZoned(value: string, min: string, max: string): string
```

Restrict `value` to the range [`min`, `max`] in zoned datetime space.

- Returns `value` if it falls within the bounds (inclusive on both ends).
- Returns `min` if `value` is before `min`.
- Returns `max` if `value` is after `max`.
- Returns `""` if any input is invalid or `min > max`.

## 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

The clamped zoned datetime string, or "" on invalid input

## Examples

```ts
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]"
```

## Source

[zoned/calculate/clampZoned.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/zoned/calculate/clampZoned.ts)
