Skip to content

Commit

Permalink
Merge pull request #70 from kaitlynmcgoldrick/fix-compare-offset-date…
Browse files Browse the repository at this point in the history
…times-error

Fix can't compare offset-naive and offset-aware datetimes error
  • Loading branch information
Hultner committed Feb 11, 2021
2 parents 89f3cf7 + bd4a63f commit fee7f42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions icalevents/icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ def __lt__(self, other):
def __str__(self):
n = now()

if not self.start.tzinfo:
self.start = normalize(self.start)
if not self.end.tzinfo:
self.end = normalize(self.end)

# compute time delta description
if not self.all_day:
if self.end > n > self.start:
Expand Down
5 changes: 5 additions & 0 deletions test/test_icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,8 @@ def test_attendee(self):
def test_organizer(self):
self.assertIsInstance(self.eventA.organizer, str)
self.assertIsInstance(self.eventB.organizer, str)

def test_str(self):
self.eventA.start = datetime(year=2017, month=2, day=3, hour=12, minute=5)
self.eventA.end = datetime(year=2017, month=2, day=3, hour=15, minute=5)
self.assertEqual('2017-02-03 12:05:00+00:00: Event A (ended)', str(self.eventA))

0 comments on commit fee7f42

Please sign in to comment.