mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Handle aware datetimes in embeds.
This commit is contained in:
parent
9c6d9f1a84
commit
1239e88d05
@ -74,7 +74,7 @@ class Embed:
|
||||
url: str
|
||||
The URL of the embed.
|
||||
timestamp: `datetime.datetime`
|
||||
The timestamp of the embed content.
|
||||
The timestamp of the embed content. This could be a naive or aware datetime.
|
||||
colour: :class:`Colour` or int
|
||||
The colour code of the embed. Aliased to ``color`` as well.
|
||||
Empty
|
||||
@ -457,7 +457,14 @@ class Embed:
|
||||
pass
|
||||
else:
|
||||
if timestamp:
|
||||
result['timestamp'] = timestamp.isoformat()
|
||||
try:
|
||||
aware = timestamp.astimezone(datetime.timezone.utc)
|
||||
except ValueError:
|
||||
# naive date time
|
||||
result['timestamp'] = timestamp.isoformat()
|
||||
else:
|
||||
result['timestamp'] = aware.isoformat().replace('+00:00', 'Z')
|
||||
|
||||
|
||||
# add in the non raw attribute ones
|
||||
if self.type:
|
||||
|
Loading…
x
Reference in New Issue
Block a user