timerange
datatypes: timerange
Subscript into a timetable by a range of times.
A utility class that selects the rows of a timetable whose times fall in an interval. The interval is half-open by default, including the time it starts at and excluding the one it ends at, so that ranges laid end to end select each row exactly once.
Source Code: timerange
The timerange class offers the following public methods:
timerange: tr = timerange (startTime, endTime)
timerange: tr = timerange (startTime, endTime, intervalType)
timerange: tr = timerange (t, unit)
timerange: tr = timerange (startTime, endTime, unit)
tr = timerange (startTime, endTime) creates a
subscript selecting the rows of a timetable whose times are at or after
startTime and strictly before endTime. The bounds may be
datetime or duration scalars, text that reads as one, or
-Inf and Inf for no bound at that end; they may not both
be infinite, there being nothing to say what kind of time is meant.
tr = timerange (startTime, endTime,
intervalType) says which bounds belong to the interval:
'openright' (the default) includes the start alone,
'openleft' the end alone, 'closed' both and
'open' neither.
tr = timerange (t, unit) covers the whole
calendar period containing t, one of 'seconds',
'minutes', 'hours', 'days', 'weeks',
'months', 'quarters' or 'years', in the
singular or the plural. t must be a datetime: a
duration is elapsed time and sits on no calendar.
tr = timerange (startTime, endTime,
unit) widens the range to whole periods of unit: it runs
from the start of the period holding startTime to the start of
the period after the one holding endTime, the far end left out
as usual. Both bounds must be datetime scalars. A unit and an
interval type cannot both be given, the unit fixing the ends itself.
timerange: tf = hasEventBounds (tr)
timerange: tr2 = resolveEventBounds (tr, tt)
Each bound becomes the time of the first event of tt its filter matches, so the range runs from the start of one event to the start of the other and stops short of it.
timerange: [lo, hi, cl, cr] = interval (tr, rowTimes)
lo and hi come back as the class of rowTimes, or as
-Inf or Inf where the range is unbounded on that side.
cl and cr say whether the interval includes the bound at
its lower and its upper end.
timerange: ix = rowIndices (tr, rowTimes)
The positions come back in ascending order, being the rows of the timetable in the order it holds them.