# Working hours total

`working-hours-total` · version 1.0.0 · Dates & times (UTC, ISO 8601) · free, no key needed

Total exact elapsed seconds in a versioned working-hours calendar after DST and closure expansion.

**Use when you need to: total working hours in date range · sum shift duration exactly · calculate elapsed office seconds.**

## Decide before calling

Read the [versioned contract](/v1/tools/working-hours-total/versions/1.0.0) and the supported scope below. Reuse `working-hours-total@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 `working-hours-total@1.0.0` for total working hours in date range. 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

- total working hours in date range
- sum shift duration exactly
- calculate elapsed office seconds
- total split-shift time
- DST-aware working time total
- sum schedule after closures
- total overridden work hours

## Not supported

- calculate payroll or wages
- round billable time
- infer public holidays

## Behavior

- Totals the union of exact UTC half-open intervals, so repeated-hour alternatives are never double-counted.
- Expansion follows RFC 9557 and ISO 8601-1:2019 under explicit DST policies.
- Pinned IANA tzdb 2025b subset only; caller_rule_version is echoed without asserting legal currency.

## Input

- `calendar` (object, required)
- `range_start_date` (string, required): pattern `^\d{4}-\d{2}-\d{2}$`
- `range_end_date` (string, required): pattern `^\d{4}-\d{2}-\d{2}$`

## Output

- `standard_version` (string, required)
- `data_version` (string, required)
- `caller_rule_version` (string, required)
- `canonical_time_zone` (string, required)
- `total_seconds` (string, required): pattern `^(0|[1-9][0-9]*)$`
- `interval_count` (integer, required): min 0; max 12000

## Limits

- max input bytes: 200000
- max days: 366
- max intervals per day: 16
- max overrides: 366
- max closures: 366
- max output intervals: 12000

## Example

Request input:

```json
{
  "calendar": {
    "time_zone": "UTC",
    "caller_rule_version": "example-v1",
    "weekly": {
      "mon": [
        {
          "start": "09:00",
          "end": "12:00"
        },
        {
          "start": "13:00",
          "end": "17:00"
        }
      ]
    },
    "overrides": [],
    "closures": [],
    "gap_policy": "reject",
    "overlap_policy": "earlier"
  },
  "range_start_date": "2025-01-06",
  "range_end_date": "2025-01-07"
}
```

Response:

```json
{
  "result": {
    "standard_version": "RFC 9557; ISO 8601-1:2019",
    "data_version": "iana-tzdb-2025b",
    "caller_rule_version": "example-v1",
    "canonical_time_zone": "UTC",
    "total_seconds": "25200",
    "interval_count": 2
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "working-hours-total",
  "version": "1.0.0",
  "input": {
    "calendar": {
      "time_zone": "UTC",
      "caller_rule_version": "example-v1",
      "weekly": {
        "mon": [
          {
            "start": "09:00",
            "end": "12:00"
          },
          {
            "start": "13:00",
            "end": "17:00"
          }
        ]
      },
      "overrides": [],
      "closures": [],
      "gap_policy": "reject",
      "overlap_policy": "earlier"
    },
    "range_start_date": "2025-01-06",
    "range_end_date": "2025-01-07"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/working-hours-total/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"calendar":{"time_zone":"UTC","caller_rule_version":"example-v1","weekly":{"mon":[{"start":"09:00","end":"12:00"},{"start":"13:00","end":"17:00"}]},"overrides":[],"closures":[],"gap_policy":"reject","overlap_policy":"earlier"},"range_start_date":"2025-01-06","range_end_date":"2025-01-07"}'
```

The machine-readable contract is at [/v1/tools/working-hours-total/versions/1.0.0](/v1/tools/working-hours-total/versions/1.0.0).

### CLI

```sh
node cli.mjs run working-hours-total 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [Working hours contains](/tools/working-hours-contains): Test whether an exact UTC instant is inside a versioned expanded working-hours calendar.
- [Working hours expand](/tools/working-hours-expand): Expand versioned weekly work schedules, overrides, closures, and DST policies into exact UTC intervals.
- [Duration application check](/tools/duration-application-check): Check a claimed timestamp from adding or subtracting an ISO 8601 duration under explicit offset and month-end rules.
- [ISO date age](/tools/iso-date-age): Compute the calendar-aware elapsed years, months, and days between a birth date and an as-of date.
- [ISO duration structure check](/tools/iso-duration-structure-check): Check a claimed reading of an ISO 8601 duration: well-formedness, components and month/day/time totals.
- [Duration convert](/tools/duration-convert): Convert a canonical integer duration between nanosecond-based SI units as an exact rational.
