Skip to content

Main content

Calendar Overlap and Common Gap Finder

Compare bounded supplied busy calendars over an explicit half-open epoch-millisecond window, deduplicating same-calendar overlap and delegating interval cells to report common gaps, overlaps and per-calendar occupied duration.

Loading tool…

Description

Compare bounded supplied busy calendars over an explicit half-open epoch-millisecond window, deduplicating same-calendar overlap and delegating interval cells to report common gaps, overlaps and per-calendar occupied duration.

A busy calendar is a collection of time intervals. A common free span has no busy calendar, while an overlap here means at least two distinct calendars are busy. Half-open intervals include their start and exclude their end, so touching events do not overlap.

Compare bounded supplied busy calendars over an explicit half-open epoch-millisecond window, deduplicating same-calendar overlap and delegating interval cells to report common gaps, overlaps and per-calendar occupied duration.

When to use this tool

Use this tool when you need the stated calculation or classification with explicit inputs, intermediate evidence, and boundary conventions.

How to use the tool and how it works

  1. Supply calendars, windowStartEpochMs, windowEndEpochMs in the field shapes below.
  2. Run the calculation. Correct format, shape, range, or undefined-statistic errors before interpreting a result.
  3. Read segments, commonFree, overlaps, calendarBusyDurationMs. Use the conventions below.

Clip supplied busy intervals to the comparison window, ignore zero-duration clipped intervals, and delegate coverage cells. Deduplicate active calendar IDs, merge adjacent equal-ID segments, and collect common-free spans, spans with at least two distinct busy calendars, and per-calendar union durations.1

Delegated operations used for this result: interval coverage multiplicity. Their calculation or parsing conventions apply to the corresponding result fields.2

Input fieldMeaning and unitsAccepted input
calendarsOpaque busy intervals [start,end); at most 16 calendars and 127 total supplied intervals. Duplicate events within one calendar do not count as different calendars.Required. Array of Object; no unknown keys.; maximum items 16.
calendars[].idLiteral identifier used independently of display labels.Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 64.
calendars[].intervalsPairs of absolute epoch milliseconds [start,end), interpreted as busy.Required. Array of Array of Safe integer.; minimum items 2; maximum items 2.; maximum items 127.
windowStartEpochMsAbsolute epoch milliseconds; timezone/recurrence normalization is caller-owned.Required. Safe integer.
windowEndEpochMsAbsolute epoch milliseconds; timezone/recurrence normalization is caller-owned.Required. Safe integer.
Output fieldInterpretationReturned shape
segmentsSegmentsRequired. Array of Object; no unknown keys.; minimum items 1; maximum items 255.
segments[].startEpochMsAbsolute epoch milliseconds; timezone/recurrence normalization is caller-owned.Required. Safe integer.
segments[].endEpochMsAbsolute epoch milliseconds; timezone/recurrence normalization is caller-owned.Required. Safe integer.
segments[].durationMsOccupied or segment duration in milliseconds, as identified by its parent record.Required. Safe integer; minimum 1.
segments[].activeCalendarIdsActive Calendar IdsRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 64.; maximum items 16.
commonFreeMaximal adjacent spans with no active calendar, in epoch milliseconds.Required. Array of Array of Safe integer.; minimum items 2; maximum items 2.; maximum items 255.
overlapsMaximal adjacent spans with two or more distinct active calendar IDs.Required. Array of Array of Safe integer.; minimum items 2; maximum items 2.; maximum items 255.
calendarBusyDurationMsCalendar Busy Duration MsRequired. Array of Object; no unknown keys.; maximum items 16.
calendarBusyDurationMs[].idLiteral identifier used independently of display labels.Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 64.
calendarBusyDurationMs[].durationMsOccupied or segment duration in milliseconds, as identified by its parent record.Required. Safe integer; minimum 0.
json
{
  "input": {
    "calendars": [
      {
        "id": "alice",
        "intervals": [
          [
            1792400400000,
            1792404000000
          ],
          [
            1792407600000,
            1792411200000
          ]
        ]
      },
      {
        "id": "bob",
        "intervals": [
          [
            1792402200000,
            1792407600000
          ]
        ]
      }
    ],
    "windowStartEpochMs": 1792400400000,
    "windowEndEpochMs": 1792414800000
  },
  "output": {
    "segments": [
      {
        "startEpochMs": 1792400400000,
        "endEpochMs": 1792402200000,
        "durationMs": 1800000,
        "activeCalendarIds": [
          "alice"
        ]
      },
      {
        "startEpochMs": 1792402200000,
        "endEpochMs": 1792404000000,
        "durationMs": 1800000,
        "activeCalendarIds": [
          "alice",
          "bob"
        ]
      },
      {
        "startEpochMs": 1792404000000,
        "endEpochMs": 1792407600000,
        "durationMs": 3600000,
        "activeCalendarIds": [
          "bob"
        ]
      },
      {
        "startEpochMs": 1792407600000,
        "endEpochMs": 1792411200000,
        "durationMs": 3600000,
        "activeCalendarIds": [
          "alice"
        ]
      },
      {
        "startEpochMs": 1792411200000,
        "endEpochMs": 1792414800000,
        "durationMs": 3600000,
        "activeCalendarIds": []
      }
    ],
    "commonFree": [
      [
        1792411200000,
        1792414800000
      ]
    ],
    "overlaps": [
      [
        1792402200000,
        1792404000000
      ]
    ],
    "calendarBusyDurationMs": [
      {
        "id": "alice",
        "durationMs": 7200000
      },
      {
        "id": "bob",
        "durationMs": 5400000
      }
    ]
  }
}

Limitations and assumptions

  • All times are absolute safe-integer epoch milliseconds and intervals are half-open. Duplicate events within one calendar do not create a cross-calendar overlap. The caller handles time zones and recurrence; no calendar account is accessed.
  • The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.

Alternative or Complementary methods

Choose the statistic according to the question and data conventions. Inspect the supplied series or matrix and the stated assumptions before comparing outputs from implementations with different defaults.

References

  1. Tool behavior and example: Calendar Overlap and Common Gap Finder — tool.io

  2. Calculation or validation: interval/interval-coverage-multiplicity — tool.io

Similar or alternative tools

  • Random Calendar Event Set Generator

    Generate exact-count date-only half-open events inside a supplied window, choosing feasible bounded durations sequentially and optionally distributing nonnegative gaps without overlaps; allowed-overlap mode uses the existing random date core, not a uniform draw over all event sets.

  • Random Booking Occupancy Dataset Generator

    Construct synthetic half-open day reservations within resource capacity, with daily occupancy, overlap evidence, and optional labeled over-capacity controls.