# Local interval compare

`local-interval-compare` · version 1.0.0 · Dates & times (UTC, ISO 8601) · free, no key needed

Normalize and compare two discrete millisecond intervals with deterministic boundary relations.

**Use when you need to: compare normalized intervals · classify two time intervals · detect interval overlap.**

## Decide before calling

Read the [versioned contract](/v1/tools/local-interval-compare/versions/1.0.0) and the supported scope below. Reuse `local-interval-compare@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `local-interval-compare@1.0.0` for compare normalized intervals. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- compare normalized intervals
- classify two time intervals
- detect interval overlap
- detect adjacent intervals
- order disjoint intervals
- compare inclusive interval boundaries

## Not supported

- compare recurring schedules
- merge interval collections
- resolve local time zones

## Behavior

- Both operands are normalized to half-open millisecond intervals before comparison.
- Relations are empty, equal, contains, contained_by, before, after, meets, met_by, or overlaps.
- Empty wins the tie-break; otherwise equality, containment, boundary contact, disjointness, then overlap.
- Caller comparison rules are versioned by caller_rule_version.

## Input

- `left` (object, required)
- `right` (object, required)
- `caller_rule_version` (string, required): min length 1; max length 64

## Output

- `standard_version` (string, required)
- `data_version` (string, required)
- `caller_rule_version` (string, required)
- `relation` (one of "empty", "equal", "contains", "contained_by", "before", "after", "meets", "met_by", "overlaps", required)
- `left_normalized` (object, required)
- `right_normalized` (object, required)

## Limits

- max input bytes: 4096
- max intervals: 2

## Example

Request input:

```json
{
  "left": {
    "start_ms": "0",
    "end_ms": "10",
    "endpoint_convention": "[)"
  },
  "right": {
    "start_ms": "10",
    "end_ms": "20",
    "endpoint_convention": "[)"
  },
  "caller_rule_version": "r1"
}
```

Response:

```json
{
  "result": {
    "standard_version": "RFC9557/RFC3339/ISO8601-1:2019",
    "data_version": "iana-tzdb-2025b-subset-nyc",
    "caller_rule_version": "r1",
    "relation": "meets",
    "left_normalized": {
      "start_ms": "0",
      "end_ms": "10",
      "endpoint_convention": "[)"
    },
    "right_normalized": {
      "start_ms": "10",
      "end_ms": "20",
      "endpoint_convention": "[)"
    }
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "local-interval-compare",
  "version": "1.0.0",
  "input": {
    "left": {
      "start_ms": "0",
      "end_ms": "10",
      "endpoint_convention": "[)"
    },
    "right": {
      "start_ms": "10",
      "end_ms": "20",
      "endpoint_convention": "[)"
    },
    "caller_rule_version": "r1"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/local-interval-compare/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"left":{"start_ms":"0","end_ms":"10","endpoint_convention":"[)"},"right":{"start_ms":"10","end_ms":"20","endpoint_convention":"[)"},"caller_rule_version":"r1"}'
```

The machine-readable contract is at [/v1/tools/local-interval-compare/versions/1.0.0](/v1/tools/local-interval-compare/versions/1.0.0).

### CLI

```sh
node cli.mjs run local-interval-compare 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [Local interval normalize](/tools/local-interval-normalize): Normalize millisecond interval endpoint conventions into a canonical half-open interval.
- [Local interval resolve](/tools/local-interval-resolve): Resolve a zoned local start/end pair to exact millisecond instants under explicit gap and overlap policies.
- [Duration compare](/tools/duration-compare): Compare two SI duration amounts after converting both to nanoseconds.
- [ISO date compare](/tools/iso-date-compare): Compare two YYYY-MM-DD calendar dates and return -1, 0, or 1.
- [ISO date range intersect](/tools/iso-date-range-intersect): Compute the intersection of two inclusive [start, end] date ranges.
- [ISO date range overlap](/tools/iso-date-range-overlap): Test whether two inclusive [start, end] date ranges share at least one day.
