module timelinelib.canvas.data.timeperiod

class timelinelib.canvas.data.timeperiod.TimePeriod[source]

Bases: object

Represents a period in time using a start and end time.

This is used both to store the time period for an event and for storing the currently displayed time period in the GUI.

__init__(start_time, end_time)[source]

Initialize self. See help(type(self)) for accurate signature.

property start_time
property end_time
property start_and_end_time
__eq__(other)[source]

Return self==value.

__ne__(other)[source]

Return self!=value.

__repr__()[source]

Return repr(self).

get_time_at_percent(percent)[source]
get_start_time()[source]
get_end_time()[source]
set_start_time(time)[source]
set_end_time(time)[source]
start_to_start(time_period)[source]
start_to_end(time_period)[source]
end_to_start(time_period)[source]
end_to_end(time_period)[source]
update(start_time, end_time, start_delta=None, end_delta=None)[source]
inside(time)[source]

Return True if the given time is inside this period or on the border, otherwise False.

distance_to(time_period)[source]
overlaps(time_period)[source]
outside_period(time_period)[source]
inside_period(time_period)[source]
starts_after(time)[source]
starts_before(time)[source]
ends_before(time)[source]
ends_after(time)[source]
ends_at(time)[source]
is_period()[source]

Return True if this time period is longer than just a point in time, otherwise False.

mean_time()[source]

Return the time in the middle if this time period is longer than just a point in time, otherwise the point in time for this time period.

duration()[source]
zoom(times, ratio=0.5)[source]
move(direction)[source]

Move this time period one 10th to the given direction.

Direction should be -1 for moving to the left or 1 for moving to the right.

move_delta(delta)[source]
delta()[source]

Return the length of this time period as a timedelta object.

center(time)[source]
has_nonzero_time()[source]
exception timelinelib.canvas.data.timeperiod.TimeOutOfRangeLeftError[source]

Bases: ValueError

exception timelinelib.canvas.data.timeperiod.TimeOutOfRangeRightError[source]

Bases: ValueError

timelinelib.canvas.data.timeperiod.time_period_center(time, length)[source]

TimePeriod factory method.

Return a time period with the given length (represented as a timedelta) centered around time.