diff options
author | 2021-08-05 17:20:31 -0700 | |
---|---|---|
committer | 2021-08-05 17:20:31 -0700 | |
commit | 24b28e264719e5bf40f565d553f7e9e57041b0a2 (patch) | |
tree | d63dbd145751a69f2cab0d242125dbe092fdfe43 | |
parent | Time: remove broken enum type check in discord_timestamp (diff) |
Time: remove timedelta and relativedelta support from discord_timestamp
When a delta is given, it is unknown what it's relative to. The function
has to assume it's relative to the POSIX Epoch. However, using a delta
for this would be quite odd, and would more likely be a mistake if
anything.
relativedelta support was broken anyway since it wasn't using the
total seconds represented by the delta.
-rw-r--r-- | bot/utils/time.py | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/bot/utils/time.py b/bot/utils/time.py index ddcf5bac2..60720031a 100644 --- a/bot/utils/time.py +++ b/bot/utils/time.py @@ -20,7 +20,7 @@ _DURATION_REGEX = re.compile( ) -ValidTimestamp = Union[int, datetime.datetime, datetime.date, datetime.timedelta, relativedelta] +ValidTimestamp = Union[int, datetime.datetime, datetime.date] class TimestampFormats(Enum): @@ -67,10 +67,6 @@ def discord_timestamp(timestamp: ValidTimestamp, format: TimestampFormats = Time timestamp = (timestamp - arrow.get(0)).total_seconds() elif isinstance(timestamp, datetime.date): timestamp = (timestamp - arrow.get(0)).total_seconds() - elif isinstance(timestamp, datetime.timedelta): - timestamp = timestamp.total_seconds() - elif isinstance(timestamp, relativedelta): - timestamp = timestamp.seconds return f"<t:{int(timestamp)}:{format.value}>" |