Jelajahi Sumber

solving bug when trying to filter an Event on a DATETIME which have no timezone

Nicolas Bonfante 9 tahun lalu
induk
melakukan
dfc215b63f
1 mengubah file dengan 6 tambahan dan 0 penghapusan
  1. 6 0
      radicale/xmlutils.py

+ 6 - 0
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