diff --git a/src/dpy_commons/text.py b/src/dpy_commons/text.py index f54f06b..8246605 100644 --- a/src/dpy_commons/text.py +++ b/src/dpy_commons/text.py @@ -7,6 +7,8 @@ import re from datetime import datetime from typing import Optional, Sequence +from discord.utils import format_dt + from .limits import MSG_LIMIT _ELLIPSIS = "…" @@ -108,9 +110,7 @@ def discord_timestamp(dt: datetime, style: str = "f") -> str: aware dt if the source is UTC; raises ValueError on an invalid style (one of t/T/d/D/f/F/R)""" if style not in _TIMESTAMP_STYLES: raise ValueError(f"invalid timestamp style '{style}'; expected one of {_TIMESTAMP_STYLES}") - if dt.tzinfo is None: - dt = dt.astimezone() - return f"" + return format_dt(dt, style) def humanize_delta(seconds: float) -> str: