Schedule package that contains classes for working with schedules.


Variables

Constants

ALL_DAYS
list[int]

List of week_day’s from week_day.MONDAY to week_day.SUNDAY

WEEKEND
list[int]

List of week_day’s from week_day.SATURDAY to week_day.SUNDAY

WORKDAYS
list[int]

List of week_day’s from week_day.MONDAY to week_day.FRIDAY


Types

Schedule

type

Data type that manages a collection of scheduling rules, allowing for specific times and exceptions to be defined.

Methods

__init__
(rules, except_once, except_yearly, timezone) -> None

Class constructor (initializer for the data type).

is_empty
() -> bool

Checks if the rules list in Schedule is empty. Returns True if list of rules is empty; otherwise, returns False.

__contains__
(t) -> bool

Checks whether a given timestamp falls within the defined schedule. Returns True if the timestamp falls within the schedule’s active periods, otherwise returns False.

__contains__
(d) -> bool

Checks whether a given timestamp falls within the defined schedule. Returns True if the timestamp falls within the schedule’s active periods, otherwise returns False.

is_same_period
(timestamp1, timestamp2) -> bool

Determines whether two timestamps fall within the same schedule period on the same day. Returns True if both timestamps fall within the same period of the schedule, even if they are in different calendar days. False if the timestamps belong to different periods within the schedule.

This method checks if two timestamps, which may belong to different calendar days, are part of the same schedule period. It handles cases where a schedule spans across two consecutive days (e.g., a trading schedule that extends past midnight) and ensures both timestamps belong to the same logical period within the schedule.

ScheduleRule

type

Data type to represent a rule for a schedule, specifying the start and end times, along with the weekdays when the rule is active.

Methods

__init__
(start, end, days) -> None

Class constructor (initializer for the data type).

Example
# this rule applies from 9:00 AM to 6:30 PM (6:30 is not included) on weekdays (Monday through Friday).
rule = ScheduleRule(start=time(hour=9), end=time(hour=18, minute=30), days=WORKDAYS)
# this overnight_rule applies from 8:15 PM to 7:30 AM on weekdays (Monday through Friday).
overnight_rule = ScheduleRule(start=time(hour=20, minute=15), end=time(hour=7, minute=30), days=WORKDAYS)
For rules that span overnight (e.g., from 10:00 PM to 6:00 AM), the end time should be on the day listed in days, while the start time is understood to be on the previous day. This allows the rule to cover activities that occur late in the evening and extend into the early hours of the next day.

Enums

week_day

enum

Enum-like class with constants for days of week.

Static fields

MONDAY
indie.schedule.week_day

Built-in constants that represent days of week.

TUESDAY
indie.schedule.week_day

Built-in constants that represent days of week.

WEDNESDAY
indie.schedule.week_day

Built-in constants that represent days of week.

THURSDAY
indie.schedule.week_day

Built-in constants that represent days of week.

FRIDAY
indie.schedule.week_day

Built-in constants that represent days of week.

SATURDAY
indie.schedule.week_day

Built-in constants that represent days of week.

SUNDAY
indie.schedule.week_day

Built-in constants that represent days of week.