From cb1f0110081fa2836a1167f7d72a44447b41c7b4 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Sun, 23 Jul 2017 22:23:01 -0400 Subject: fix timezone --- email_helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'email_helpers.py') 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: -- cgit v1.2.3-70-g09d2