# intervalCountTime

Industry: Core

## Signature

```ts
intervalCountTime(start: string, end: string, unit: string): number | null
```

Count how many `unit` boundaries a time interval crosses.

- Counts clock boundaries touched by the half-open interval `[start, end)` — distinct from `diffTime`, which measures exact elapsed duration. An interval from 12:59 to 13:01 is two minutes long but touches 2 hour boundaries.
- The end boundary is excluded: `"12:00:00"` to `"14:00:00"` counts 2 hours.
- A zero-length interval (`start === end`) returns `0`: the empty `[start, start)` holds no instant, so it touches no unit (before 1.16.0 it counted 1 when mid-unit).
- Accepts singular or plural units (`"hour"` and `"hours"` behave identically).
- Returns `null` on invalid input (unparseable start/end, `start > end`, unsupported unit, or a unit that has no effect on `PlainTime`, e.g. `"days"`).

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `start` | `string` | ISO PlainTime string for the interval start |
| `end` | `string` | ISO PlainTime string for the interval end |
| `unit` | `string` | unit string — `"hour" \| "minute" \| "second" \| "millisecond" \| "microsecond" \| "nanosecond"` (calendar units return null) |

## Returns

number of unit boundaries touched, or null on invalid input

## Examples

```ts
import { intervalCountTime } from "@northguild/gmt/plain/interval";

intervalCountTime("12:00:00", "14:00:00", "hour") // 2
```

## Source

[plain/interval/intervalCountTime.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/plain/interval/intervalCountTime.ts)
