Initial support for Discord timestamping (#5155)

* Initial support for Discord timestamping

* Fix timezones

* Fix userinfo for users with member.joined_at equal to None

* Simplify

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Kowlin
2021-08-31 21:55:33 +02:00
committed by GitHub
parent b586c2f990
commit f05debc923
3 changed files with 17 additions and 23 deletions

View File

@@ -432,9 +432,9 @@ class Case:
until = None
duration = None
if self.until:
start = datetime.utcfromtimestamp(self.created_at)
end = datetime.utcfromtimestamp(self.until)
end_fmt = end.strftime("%Y-%m-%d %H:%M:%S UTC")
start = datetime.fromtimestamp(self.created_at, tz=timezone.utc)
end = datetime.fromtimestamp(self.until, tz=timezone.utc)
end_fmt = f"<t:{int(end.timestamp())}>"
duration = end - start
dur_fmt = _strfdelta(duration)
until = end_fmt
@@ -454,9 +454,7 @@ class Case:
last_modified = None
if self.modified_at:
last_modified = "{}".format(
datetime.utcfromtimestamp(self.modified_at).strftime("%Y-%m-%d %H:%M:%S UTC")
)
last_modified = f"<t:{self.modified_at}>"
if isinstance(self.user, int):
if self.user == 0xDE1: