diff --git a/bugwarrior/services/__init__.py b/bugwarrior/services/__init__.py index 20e1b8747..1624d8e8c 100644 --- a/bugwarrior/services/__init__.py +++ b/bugwarrior/services/__init__.py @@ -9,7 +9,7 @@ from pkg_resources import iter_entry_points from dateutil.parser import parse as parse_date -from dateutil.tz import tzlocal, tzutc +from dateutil.tz import tzlocal from jinja2 import Template import pytz import six @@ -346,8 +346,6 @@ def parse_date(self, date, timezone='UTC'): if not date.tzinfo: if timezone == LOCAL_TIMEZONE: tzinfo = tzlocal() - elif timezone == 'UTC': - tzinfo = tzutc() else: tzinfo = pytz.timezone(timezone) date = date.replace(tzinfo=tzinfo) diff --git a/bugwarrior/services/gmail.py b/bugwarrior/services/gmail.py index e1e72be06..1081ad4bb 100644 --- a/bugwarrior/services/gmail.py +++ b/bugwarrior/services/gmail.py @@ -97,8 +97,8 @@ def get_annotations(self): return self.extra.get('annotations', []) def get_entry(self): - date_string = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(self.extra['internal_date']) / 1000)) - return self.parse_date(date_string, 'UTC') + date_string = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(int(self.extra['internal_date']) / 1000)) + return self.parse_date(date_string) class GmailService(IssueService): diff --git a/tests/test_gmail.py b/tests/test_gmail.py index 58e83ab59..54aa3eda7 100644 --- a/tests/test_gmail.py +++ b/tests/test_gmail.py @@ -1,8 +1,8 @@ import os.path -import dateutil from datetime import datetime import mock +from dateutil.tz import tzutc import bugwarrior.services.gmail as gmail from .base import ServiceTest, AbstractServiceTest @@ -86,7 +86,7 @@ def test_to_taskwarrior(self): gmail.thread_extras(thread, self.service.get_labels())) expected = { 'annotations': [], - 'entry': datetime(2019, 1, 5, 16, 7, 47, tzinfo=dateutil.tz.tz.tzutc()), + 'entry': datetime(2019, 1, 5, 21, 7, 47, tzinfo=tzutc()), 'gmailthreadid': '1234', 'gmaillastmessageid': 'CMCRSF+6r=x5JtW4wlRYR5qdfRq+iAtSoec5NqrHvRpvVgHbHdg@mail.gmail.com', 'gmailsnippet': 'Bugwarrior is great', @@ -107,7 +107,7 @@ def test_issues(self): issue = next(self.service.issues()) expected = { 'annotations': ['@Foo Bar - Regarding Bugwarrior'], - 'entry': datetime(2019, 1, 5, 16, 7, 47, tzinfo=dateutil.tz.tz.tzutc()), + 'entry': datetime(2019, 1, 5, 21, 7, 47, tzinfo=tzutc()), 'gmailthreadid': '1234', 'gmaillastmessageid': 'CMCRSF+6r=x5JtW4wlRYR5qdfRq+iAtSoec5NqrHvRpvVgHbHdg@mail.gmail.com', 'gmailsnippet': 'Bugwarrior is great',