From dfc215b63f21aefb94f14ef34bee1deb25ee8551 Mon Sep 17 00:00:00 2001 From: Nicolas Bonfante Date: Fri, 24 Jun 2016 14:02:35 +0200 Subject: [PATCH] solving bug when trying to filter an Event on a DATETIME which have no timezone --- radicale/xmlutils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 1394382..3524f46 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -220,6 +220,9 @@ def _time_range_match(vobject_item, filter_, child_name): if child_name == "VEVENT": # TODO: check if there's a timezone dtstart = child.dtstart.value + if isinstance(dtstart, datetime) and not dtstart.tzinfo: + dtstart = dtstart.replace(tzinfo=timezone.utc) + if not isinstance(dtstart, datetime): dtstart_is_datetime = False # TODO: changing dates to datetimes may be wrong because of tz @@ -235,6 +238,9 @@ def _time_range_match(vobject_item, filter_, child_name): if not isinstance(dtend, datetime): dtend = datetime.combine(dtend, datetime.min.time()).replace( tzinfo=timezone.utc) + if isinstance(dtend, datetime) and not dtend.tzinfo: + dtend = dtend.replace(tzinfo=timezone.utc) + return start < dtend and end > dtstart elif duration is not None: duration = duration.value