Skip to main content

Function: overlap()

overlap(a, b): TimeSpan | undefined

Defined in: time/instant.ts:95

The part a and b share, or undefined when they do not touch. Half-open, like every stored TimeSpan (plans/01 §5): two spans that only touch at a boundary — a.end === b.start — share no instant, so that case answers undefined too, not a zero-length span.

The library clips a TimeSpan to a window this way in three places already (layout/frame.ts's box clip, time-shading-covers.ts's day clip, time/scale.ts's tick clip); this is that one rule, public. Without it a consumer totalling a Field over gantt.visibleSpan has to write Math.max/Math.min on two Instants and cast the bare number back — the hand arithmetic I10 exists to stop (#472).

Parameters​

a​

TimeSpan

b​

TimeSpan

Returns​

TimeSpan | undefined