Skip to main content
Version: V2 (Ignition 8.1)

tamaki.mes.utils.calculateOverlappingDuration

Description​

Returns the overlapping duration between two intervals. Each interval is defined by a start and end value (typically epoch milliseconds). The overlap is the difference between the latest start and the earliest end; if the intervals do not overlap, the function returns 0. The result is in the same units as the inputs.

Syntax​

tamaki.mes.utils.calculateOverlappingDuration(start1, end1, start2, end2)

Parameters​

ParameterTypeNullableDescription
start1NumberFalseStart of the first interval (epoch time).
end1NumberFalseEnd of the first interval (epoch time).
start2NumberFalseStart of the second interval (epoch time).
end2NumberFalseEnd of the second interval (epoch time).

Returns​

A Number: the overlapping duration in the same units as the inputs, or 0 if there is no overlap.

Code Examples​

# Two 1-hour windows overlapping by 30 minutes (epoch millis)
overlapMs = tamaki.mes.utils.calculateOverlappingDuration(
0, 3600000,
1800000, 5400000
)
# 1800000 (30 minutes)