-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Convenience Functionality for BusinessOpeningHours #4861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Aweryc
wants to merge
10
commits into
python-telegram-bot:master
Choose a base branch
from
Aweryc:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b175dab
Convenience Functionality for BusinessOpeningHours
Aweryc 49aa14b
Merge pull request #1 from Aweryc/convenience-functionalty-BOH
Aweryc 0cd3963
Merge branch 'master' into master
Aweryc e3132e9
Update changes/unreleased/48XX._.toml
Aweryc fa4e6cd
Update src/telegram/_utils/datetime.py
Aweryc 9c183e7
Update src/telegram/_utils/datetime.py
Aweryc 0b836cf
Update tests/_utils/test_datetime.py
Aweryc 5a91e66
Rename 48XX._.toml to 4861.HEoGVs2mYXWzqMahi6SEhV.toml
Aweryc 869748e
Merge branch 'python-telegram-bot:master' into master
Aweryc 83cb615
Update pyproject.toml
Aweryc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
features = "Added a two methods for BusinessOpeningHours" | ||
[[pull_requests]] | ||
uid = "4326" | ||
author_uid = "Aweryc" | ||
closes_threads = ["4194"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -31,6 +31,7 @@ | |||||
import datetime as dtm | ||||||
import os | ||||||
import time | ||||||
import zoneinfo | ||||||
from typing import TYPE_CHECKING, Optional, Union | ||||||
|
||||||
from telegram._utils.warnings import warn | ||||||
|
@@ -230,6 +231,28 @@ def _datetime_to_float_timestamp(dt_obj: dtm.datetime) -> float: | |||||
return dt_obj.timestamp() | ||||||
|
||||||
|
||||||
def verify_timezone( | ||||||
tz: Optional[Union[dtm.tzinfo, zoneinfo.ZoneInfo]], | ||||||
) -> Optional[Union[zoneinfo.ZoneInfo, dtm.tzinfo]]: | ||||||
""" | ||||||
Verifies that the given timezone is a valid timezone. | ||||||
""" | ||||||
|
||||||
if tz is None: | ||||||
return None | ||||||
if isinstance(tz, (dtm.tzinfo, zoneinfo.ZoneInfo)): | ||||||
return tz | ||||||
|
||||||
try: | ||||||
return zoneinfo.ZoneInfo(tz) | ||||||
except zoneinfo.ZoneInfoNotFoundError as err: | ||||||
raise TelegramError( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
f"No time zone found with key {tz}. " | ||||||
f"Make sure to use a valid time zone name and " | ||||||
f"correct install tzdata (https://pypi.org/project/tzdata/)" | ||||||
) from err | ||||||
|
||||||
|
||||||
def get_timedelta_value( | ||||||
value: Optional[dtm.timedelta], attribute: str | ||||||
) -> Optional[Union[int, dtm.timedelta]]: | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.