aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-10-11 21:08:31 +0200
committerGravatar Johannes Christ <[email protected]>2019-10-11 21:08:31 +0200
commit372f35c8e90ad7c2a3babfd31a9c396860737934 (patch)
tree8d970003849968e16ce0cd4472c792f826c553de
parentMerge branch 'master' into bot-utils-time-tests (diff)
Add typehints.
-rw-r--r--bot/utils/time.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/bot/utils/time.py b/bot/utils/time.py
index 4fbf66f22..183eff986 100644
--- a/bot/utils/time.py
+++ b/bot/utils/time.py
@@ -84,20 +84,19 @@ def time_since(past_datetime: datetime.datetime, precision: str = "seconds", max
return f"{humanized} ago"
-def parse_rfc1123(stamp: str):
+def parse_rfc1123(stamp: str) -> datetime.datetime:
"""Parse RFC1123 time string into datetime."""
return datetime.datetime.strptime(stamp, RFC1123_FORMAT).replace(tzinfo=datetime.timezone.utc)
# Hey, this could actually be used in the off_topic_names and reddit cogs :)
-async def wait_until(time: datetime.datetime, start: Optional[datetime.datetime] = None):
+async def wait_until(time: datetime.datetime, start: Optional[datetime.datetime] = None) -> None:
"""
Wait until a given time.
:param time: A datetime.datetime object to wait until.
:param start: The start from which to calculate the waiting duration. Defaults to UTC time.
"""
-
delay = time - (start or datetime.datetime.utcnow())
delay_seconds = delay.total_seconds()