aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/recruitment/talentpool/_review.py4
-rw-r--r--bot/exts/utils/utils.py2
-rw-r--r--bot/utils/time.py15
3 files changed, 13 insertions, 8 deletions
diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py
index bbffbe6e3..474f669c6 100644
--- a/bot/exts/recruitment/talentpool/_review.py
+++ b/bot/exts/recruitment/talentpool/_review.py
@@ -273,7 +273,7 @@ class Reviewer:
last_channel = user_activity["top_channel_activity"][-1]
channels += f", and {last_channel[1]} in {last_channel[0]}"
- joined_at_formatted = time.time_since(member.joined_at)
+ joined_at_formatted = time.format_relative(member.joined_at)
review = (
f"{member.name} joined the server **{joined_at_formatted}**"
f" and has **{messages} messages**{channels}."
@@ -365,7 +365,7 @@ class Reviewer:
nomination_times = f"{num_entries} times" if num_entries > 1 else "once"
rejection_times = f"{len(history)} times" if len(history) > 1 else "once"
- end_time = time.time_since(isoparse(history[0]['ended_at']))
+ end_time = time.format_relative(isoparse(history[0]['ended_at']))
review = (
f"They were nominated **{nomination_times}** before"
diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py
index 00fa7a388..2a074788e 100644
--- a/bot/exts/utils/utils.py
+++ b/bot/exts/utils/utils.py
@@ -172,7 +172,7 @@ class Utils(Cog):
lines = []
for snowflake in snowflakes:
created_at = snowflake_time(snowflake)
- lines.append(f"**{snowflake}**\nCreated at {created_at} ({time.time_since(created_at)}).")
+ lines.append(f"**{snowflake}**\nCreated at {created_at} ({time.format_relative(created_at)}).")
await LinePaginator.paginate(
lines,
diff --git a/bot/utils/time.py b/bot/utils/time.py
index 545e50859..e6dcdee15 100644
--- a/bot/utils/time.py
+++ b/bot/utils/time.py
@@ -125,7 +125,7 @@ def humanize_delta(delta: relativedelta, precision: str = "seconds", max_units:
def get_time_delta(time_string: str) -> str:
"""Returns the time in human-readable time delta format."""
date_time = dateutil.parser.isoparse(time_string)
- time_delta = time_since(date_time)
+ time_delta = format_relative(date_time)
return time_delta
@@ -161,9 +161,14 @@ def relativedelta_to_timedelta(delta: relativedelta) -> datetime.timedelta:
return utcnow + delta - utcnow
-def time_since(past_datetime: datetime.datetime) -> str:
- """Takes a datetime and returns a discord timestamp that describes how long ago that datetime was."""
- return discord_timestamp(past_datetime, TimestampFormats.RELATIVE)
+def format_relative(timestamp: ValidTimestamp) -> str:
+ """
+ Format `timestamp` as a relative Discord timestamp.
+
+ A relative timestamp describes how much time has elapsed since `timestamp` or how much time
+ remains until `timestamp` is reached. See `time.discord_timestamp`.
+ """
+ return discord_timestamp(timestamp, TimestampFormats.RELATIVE)
def format_infraction(timestamp: str) -> str:
@@ -211,7 +216,7 @@ def until_expiration(
Get the remaining time until infraction's expiration, in a discord timestamp.
Returns a human-readable version of the remaining duration between arrow.utcnow() and an expiry.
- Similar to time_since, except that this function doesn't error on a null input
+ Similar to format_relative, except that this function doesn't error on a null input
and return null if the expiry is in the paste
"""
if not expiry: