# ISO date-time clamp

`iso-datetime-clamp` · version 1.0.0 · Dates & times (UTC, ISO 8601) · free, no key needed

Clamp a strict UTC ISO-8601 datetime into an inclusive [min, max] range.

**Use when you need to: iso datetime clamp · bound datetime to range · restrict utc datetime to min max.**

## Supported

- iso datetime clamp
- bound datetime to range
- restrict utc datetime to min max

## Not supported

- leap seconds
- time zones
- offsets other than Z
- fractional seconds
- open ranges

## Behavior

- datetime, min, and max must match YYYY-MM-DDTHH:MM:SSZ with zero-padded fields and a real proleptic Gregorian UTC civil time, years 0001-9999.
- min must not be after max on the UTC millisecond timeline, or the call is rejected.
- If datetime is before min, the result is min. If datetime is after max, the result is max. Otherwise the result is datetime unchanged.

## Input

- `datetime` (string, required): min length 20; max length 20; pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`
- `min` (string, required): min length 20; max length 20; pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`
- `max` (string, required): min length 20; max length 20; pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`

## Output

- `datetime` (string, required): min length 20; max length 20

## Limits

- min year: 1
- max year: 9999

## Example

Request input:

```json
{
  "datetime": "2026-09-15T00:00:00Z",
  "min": "2026-09-15T08:00:00Z",
  "max": "2026-09-15T18:00:00Z"
}
```

Response:

```json
{
  "result": {
    "datetime": "2026-09-15T08:00:00Z"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "iso-datetime-clamp",
  "version": "1.0.0",
  "input": {
    "datetime": "2026-09-15T00:00:00Z",
    "min": "2026-09-15T08:00:00Z",
    "max": "2026-09-15T18:00:00Z"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/iso-datetime-clamp/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"datetime":"2026-09-15T00:00:00Z","min":"2026-09-15T08:00:00Z","max":"2026-09-15T18:00:00Z"}'
```

The machine-readable contract is at [/v1/tools/iso-datetime-clamp/versions/1.0.0](/v1/tools/iso-datetime-clamp/versions/1.0.0).

### CLI

```sh
node cli.mjs run iso-datetime-clamp 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [ISO date clamp](/tools/iso-date-clamp): Clamp a YYYY-MM-DD calendar date into an inclusive [min, max] range.
- [ISO date-time add seconds](/tools/iso-datetime-add-seconds): Add a signed whole-second delta to a strict UTC ISO-8601 datetime.
- [ISO date-time truncate](/tools/iso-datetime-truncate): Truncate a strict UTC ISO-8601 datetime toward UTC zero at day, hour, minute, or second.
- [ISO date min max](/tools/iso-date-min-max): Return the earliest and latest date in a non-empty array of YYYY-MM-DD calendar dates.
- [ISO date-time compare](/tools/iso-datetime-compare): Compare two strict UTC ISO-8601 datetimes and return -1, 0, or 1.
- [ISO date-time diff seconds](/tools/iso-datetime-diff-seconds): Return the signed whole-second difference between two strict UTC ISO-8601 datetimes.
