aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/cogs/watchchannels/talentpool.py5
-rw-r--r--bot/cogs/watchchannels/watchchannel.py8
-rw-r--r--bot/utils/time.py3
3 files changed, 5 insertions, 11 deletions
diff --git a/bot/cogs/watchchannels/talentpool.py b/bot/cogs/watchchannels/talentpool.py
index ffe7693a9..4a23902d5 100644
--- a/bot/cogs/watchchannels/talentpool.py
+++ b/bot/cogs/watchchannels/talentpool.py
@@ -10,6 +10,7 @@ from bot.api import ResponseCodeError
from bot.constants import Channels, Guild, Roles, Webhooks
from bot.decorators import with_role
from bot.pagination import LinePaginator
+from bot.utils import time
from .watchchannel import WatchChannel, proxy_user
log = logging.getLogger(__name__)
@@ -198,7 +199,7 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"):
log.debug(active)
log.debug(type(nomination_object["inserted_at"]))
- start_date = self._get_human_readable(nomination_object["inserted_at"])
+ start_date = time.format_infraction(nomination_object["inserted_at"])
if active:
lines = textwrap.dedent(
f"""
@@ -212,7 +213,7 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"):
"""
)
else:
- end_date = self._get_human_readable(nomination_object["ended_at"])
+ end_date = time.format_infraction(nomination_object["ended_at"])
lines = textwrap.dedent(
f"""
===============
diff --git a/bot/cogs/watchchannels/watchchannel.py b/bot/cogs/watchchannels/watchchannel.py
index e78282900..f706ff634 100644
--- a/bot/cogs/watchchannels/watchchannel.py
+++ b/bot/cogs/watchchannels/watchchannel.py
@@ -329,14 +329,6 @@ class WatchChannel(metaclass=CogABCMeta):
return time_delta
- @staticmethod
- def _get_human_readable(time_string: str, output_format: str = "%Y-%m-%d %H:%M:%S") -> str:
- date_time = datetime.datetime.strptime(
- time_string,
- "%Y-%m-%dT%H:%M:%S.%fZ"
- ).replace(tzinfo=None)
- return date_time.strftime(output_format)
-
def _remove_user(self, user_id: int) -> None:
"""Removes a user from a watch channel."""
self.watched_users.pop(user_id, None)
diff --git a/bot/utils/time.py b/bot/utils/time.py
index 0d4192921..da28f2c76 100644
--- a/bot/utils/time.py
+++ b/bot/utils/time.py
@@ -1,6 +1,7 @@
import asyncio
import datetime
+import dateutil.parser
from dateutil.relativedelta import relativedelta
RFC1123_FORMAT = "%a, %d %b %Y %H:%M:%S GMT"
@@ -100,4 +101,4 @@ async def wait_until(time: datetime.datetime) -> None:
def format_infraction(timestamp: str) -> str:
"""Format an infraction timestamp to a more readable ISO 8601 format."""
- return datetime.datetime.fromisoformat(timestamp[:-1]).strftime(INFRACTION_FORMAT)
+ return dateutil.parser.isoparse(timestamp).strftime(INFRACTION_FORMAT)