BusinessOpeningHours

class telegram.BusinessOpeningHours(time_zone_name, opening_hours, *, api_kwargs=None)[source]

Bases: telegram.TelegramObject

This object describes the opening hours of a business.

Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their time_zone_name and opening_hours are equal.

Added in version 21.1.

Parameters:
time_zone_name[source]

Unique name of the time zone for which the opening hours are defined.

Type:

str

opening_hours[source]

List of time intervals describing business opening hours.

Type:

Sequence[telegram.BusinessOpeningHoursInterval]

classmethod de_json(data, bot=None)[source]

See telegram.TelegramObject.de_json().

get_opening_hours_for_day(date, time_zone=None)[source]

Returns the opening hours intervals for a specific day as datetime objects.

Added in version 22.5.

Parameters:
  • date (datetime.date) – The date to get opening hours for.

  • time_zone (datetime.tzinfo | str, optional) – Timezone to use for the returned datetime objects. If not specified, then time_zone_name be used.

Returns:

A tuple of datetime pairs representing opening and closing times for the specified day. Each pair consists of (opening_time, closing_time). Returns an empty tuple if there are no opening hours for the given day.

Return type:

tuple[tuple[datetime.datetime, datetime.datetime], …]

is_open(datetime)[source]

Check if the business is open at the specified datetime.

Added in version 22.5.

Parameters:

datetime (datetime.datetime) – The datetime to check. If the object is timezone-naive, it is assumed to be in the timezone specified by time_zone_name.

Returns:

True if the business is open at the specified time, False otherwise.

Return type:

bool