Skip to content

Time

kloppy.domain.Time dataclass

Time(period, timestamp)

A point in time during a match.

A time is defined by a period and a timestamp. The timestamp is the time elapsed since the start of the period.

ATTRIBUTE DESCRIPTION
period

A period in a match.

TYPE: Period

timestamp

The time elapsed since the start of the period.

TYPE: timedelta

period instance-attribute

period

timestamp instance-attribute

timestamp

from_period classmethod

from_period(period, type_='start')
Source code in kloppy/domain/models/time.py
@classmethod
def from_period(
    cls,
    period: Period,
    type_: Union[Literal["start"], Literal["end"]] = "start",
):
    return cls(
        period=period,
        timestamp=timedelta(0) if type_ == "start" else period.duration,
    )