Skip to content

Commit

Permalink
Handle non-naive dates correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-mailosaur committed Oct 17, 2020
1 parent 6e8c4ed commit 0cf872f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mailosaur/operations/messages_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def list(self, server, page=None, items_per_page=None, received_after=None):
url = "%sapi/messages" % (self.base_url)

if received_after is not None:
received_after = self.timezone.localize(received_after).isoformat()
if received_after.tzinfo is None or received_after.tzinfo.utcoffset(received_after) is None:
received_after = self.timezone.localize(received_after)
received_after = received_after.isoformat()

params = {'server': server, 'page': page, 'itemsPerPage': items_per_page, 'receivedAfter': received_after}
response = self.session.get(url, params=params)
Expand Down Expand Up @@ -174,7 +176,9 @@ def search(self, server, criteria, page=None, items_per_page=None, timeout=None,
url = "%sapi/messages/search" % (self.base_url)

if received_after is not None:
received_after = self.timezone.localize(received_after).isoformat()
if received_after.tzinfo is None or received_after.tzinfo.utcoffset(received_after) is None:
received_after = self.timezone.localize(received_after)
received_after = received_after.isoformat()

params = {'server': server, 'page': page, 'itemsPerPage': items_per_page, 'receivedAfter': received_after}

Expand Down

0 comments on commit 0cf872f

Please sign in to comment.