Handle aware datetimes in embeds.
This commit is contained in:
parent
9c6d9f1a84
commit
1239e88d05
@ -74,7 +74,7 @@ class Embed:
|
|||||||
url: str
|
url: str
|
||||||
The URL of the embed.
|
The URL of the embed.
|
||||||
timestamp: `datetime.datetime`
|
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
|
colour: :class:`Colour` or int
|
||||||
The colour code of the embed. Aliased to ``color`` as well.
|
The colour code of the embed. Aliased to ``color`` as well.
|
||||||
Empty
|
Empty
|
||||||
@ -457,7 +457,14 @@ class Embed:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if timestamp:
|
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
|
# add in the non raw attribute ones
|
||||||
if self.type:
|
if self.type:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user