aboutsummaryrefslogtreecommitdiff
path: root/discord/embeds.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-03-13 17:47:46 -0400
committerRapptz <[email protected]>2017-03-13 17:47:46 -0400
commit1239e88d0521d5f4d2251629f4be2c2650619b9f (patch)
treee8fa100543e827b8f460c406924d7b9602ce07c6 /discord/embeds.py
parentRemove call handling for now. (diff)
downloaddiscord.py-1239e88d0521d5f4d2251629f4be2c2650619b9f.tar.xz
discord.py-1239e88d0521d5f4d2251629f4be2c2650619b9f.zip
Handle aware datetimes in embeds.
Diffstat (limited to 'discord/embeds.py')
-rw-r--r--discord/embeds.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/discord/embeds.py b/discord/embeds.py
index 9d3d604e..30620498 100644
--- a/discord/embeds.py
+++ b/discord/embeds.py
@@ -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: