pipeline.domain.measures.TimeInterval
- class TimeInterval(start: datetime | None = None, end: datetime | None = None)[source]
Bases:
objectLogical representation of a time interval.
- start
start time of interval, as datetime object.
- end
end time of interval, as datetime object.
Methods
Returns True if time is contained in this interval.
Returns True if this TimeInterval is empty.
Returns True if this interval overlaps with the given interval.
Returns an open-ended TimeInterval starting from the given time.
Returns an open-ended TimeInterval starting from now.
Attributes
FOREVER- __init__(start: datetime | None = None, end: datetime | None = None) None[source]
Initialize a TimeInterval object.
- Parameters:
start -- start time of interval, as datetime object.
end -- end time of interval, as datetime object.
- contains(time: datetime | TimeInterval) bool[source]
Returns True if time is contained in this interval.
Note that this interval is half-open; it does not include its ending point. Note also that an interval that is equal to this one is not contained by this one. The best analogy is that of a rigid box with infinitely thin walls: a box that is exactly the same as another cannot fit inside it.
- Parameters:
time -- The datetime or TimeInterval to be tested for containment.
- Returns:
True if time is contained in this interval.
- overlaps(ti: TimeInterval) bool[source]
Returns True if this interval overlaps with the given interval.
- Parameters:
ti -- TimeInterval object to test overlap with.
- Returns:
Boolean denoting whether this time interval overlaps with given interval.
- classmethod starting_from(start: datetime) TimeInterval[source]
Returns an open-ended TimeInterval starting from the given time.
- Parameters:
start (object) -- Datetime object denoting start time of interval.
- Returns:
TimeInterval object from given time until 31-12-9999.
- classmethod starting_from_now() TimeInterval[source]
Returns an open-ended TimeInterval starting from now.
- Returns:
TimeInterval object.