msticpy.common.timespan module

Timespan class.

class msticpy.common.timespan.TimeSpan(*args, timespan: TimeSpan | Tuple[Any, Any] | Any | None = None, start: datetime | str | None = None, end: datetime | str | None = None, period: timedelta | str | None = None)

Bases: object

Timespan parameter for notebook modules.

Initialize Timespan.

Parameters:
  • timespan (Union(TimeSpan, Tuple(Any, Any), Any), optional) – A TimeSpan object or a tuple of datetimes or datetime strings, or an object that has either start and end or start and period date_time-like attributes. By default None

  • start (Optional[Union[datetime, str]], optional) – datetime of the start of the time period, by default None

  • end (Optional[Union[datetime, str]], optional) – datetime of the end of the time period, by default utcnow

  • period (Optional[Union[timedelta, str]], optional) – duration of the period, by default None

  • parameters (If passed unnamed)

  • of (the arguments can one)

  • strings) (- a TimeSpan object (or a tuple of start/end dates or)

  • datetime (- a start datetime and and end)

  • period. (- a start datetime and a numeric)

Raises:

ValueError – If neither start nor period are specified.

property end: datetime

Return the end of the timeperiod.

Returns:

End datetime.

Return type:

datetime

property period: timedelta

Return the period of the timeperiod.

Returns:

Period timedelta.

Return type:

timedelta

property start: datetime

Return the start of the timeperiod.

Returns:

Start datetime.

Return type:

datetime