Skip to content

Commit

Permalink
Merge pull request #685 from ralphbean/fix-tz
Browse files Browse the repository at this point in the history
Fix UTC discrepancy.
  • Loading branch information
ralphbean committed Aug 3, 2019
2 parents 51718f2 + 0c565a4 commit 4c5c866
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions bugwarrior/services/__init__.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions bugwarrior/services/gmail.py
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions 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
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 4c5c866

Please sign in to comment.