aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-07-23 22:23:01 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2017-07-23 22:23:01 -0400
commitcb1f0110081fa2836a1167f7d72a44447b41c7b4 (patch)
tree5c7eab0ed519c1c0d1a11e3bc0ca26fe67a1fa14
parenta795afbd6c1d6884e265e502790c3b20ff9205d3 (diff)
downloadfamille-flask-cb1f0110081fa2836a1167f7d72a44447b41c7b4.tar.gz
fix timezone
-rw-r--r--email_helpers.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/email_helpers.py b/email_helpers.py
index 8a71b09..8f5b2ac 100644
--- a/email_helpers.py
+++ b/email_helpers.py
@@ -11,6 +11,7 @@ import email
from email.utils import parseaddr, parsedate_to_datetime
import argparse
from bs4 import BeautifulSoup
+from pytz import timezone
SCOPES = 'https://www.googleapis.com/auth/gmail.modify'
CLIENT_SECRET_FILE = os.path.expanduser('~/client_id.json')
@@ -148,7 +149,9 @@ if __name__ == "__main__":
elif body.get_content_type() == 'text/plain':
comment = comment_cache = body.get_content()
news_id = int(m.groups()[0])
- date = parsedate_to_datetime(mail['Date'])
+ date = (parsedate_to_datetime(mail['Date']).
+ astimezone(timezone('utc')).
+ replace(tzinfo=None))
try:
db.execute(sql_str, (date, news_id, user_id, comment, comment_cache))
except sqlite3.Error as e: