changeset 12:4747393db602

Decode messages send time and provide a nicer representation in emails
author Daniele Nicolodi <daniele@grinta.net>
date Mon, 11 Jan 2016 21:15:53 +0100
parents f3d6d73a7184
children 37ce0dc68cad
files bnpparibas.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/bnpparibas.py	Mon Jan 11 21:14:54 2016 +0100
+++ b/bnpparibas.py	Mon Jan 11 21:15:53 2016 +0100
@@ -13,6 +13,7 @@
 import time
 
 from contextlib import contextmanager
+from datetime import datetime
 from email.mime.text import MIMEText
 from email.utils import format_datetime, localtime, parseaddr
 from io import BytesIO
@@ -29,7 +30,7 @@
 MESSAGE = """\
 From: {message.sender:}
 Subject: {message.subject:}
-Date: {message.date:}
+Date: {message.date:%a, %d %b %Y %H:%M:%S}
 
 {message.body:}
 """
@@ -163,7 +164,7 @@
     @classmethod
     def fromjson(cls, x):
         data = {'id': x['msg']['id'],
-                'date': x['msg']['id'],
+                'date': datetime.strptime(x['msg']['id'], '%Y-%m-%d-%H.%M.%S.%f'),
                 'subject': x['msg']['objet'],
                 'sender': x['msg']['emetteur']['nom'],
                 'content': x['msg']['contenu'],