Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Convenience Functionalty forBusinessOpeningHours #4194

@Bibo-Joshi

Description

@Bibo-Joshi

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

API 7.2 introducedBusinessOpeningHours andBOHInterval. Parsing this information for different use cases can require some logic on the bot side. It would be nice to have functionality that allows to

  • check if the business is open at a given time
  • get the opening hours for a given day

Both should be able to deal with timezones

Describe the solution you'd like

Add a methodBOH.get_opening_hours_for_day(dtm.date, tzinfo=None) -> tuple[tuple[dtm.datetime, dtm.datetime], …].
The user would provide a specific day and optionally a timezone/tzinfo object and get as return value a sequence of the opening intervals for that day in the desired timezone. If no tzinfo is provided, `BOH.time_zone_namez should be used

Add a methodBOH.is_open(dtm.datetime) -> bool, i.e. a method that would allow you to check if the business is open at that specified time. If the parameter is tz-aware, the return value should be considered for that timezone. If it's timezone naive, it should be considered inBOH.time_zone_name.

Describe alternatives you've considered

No response

Additional context

See discussion in#4183

Handling of timezones currently requires additional dependencies like pytz. Once we drop support for Python3.8, we can instead usezoneinfo which as added to the std-lib in py3.9. Adding the 1st-party libtzdata as required dependency to PTB would probably not be a bummer to me, though I'd also be okay with not doing that and instead giving hints to users that they might need to install that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    3.9 - starting 10-2024

    Status

    3.9 - starting 10-2024

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp