From e1f3045f1f62992538e63a309ad480032d55c079 Mon Sep 17 00:00:00 2001 From: Nicolas Bonfante Date: Wed, 15 Jun 2016 09:55:30 +0200 Subject: [PATCH] adding VJournal method --- radicale/xmlutils.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 4f6a84c..915d9a3 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -250,12 +250,34 @@ def _time_range_match(vobject_item, filter_, child_name): else: # Line 5 return start < dtstart + timedelta(days=1) and end > dtstart - elif child_name == "VTODO": + elif child_name == "VTODO": # TODO: implement this pass elif child_name == "VJOURNAL": - # TODO: implement this - pass + dtstart = getattr(child, "dstart", None) + + if dtstart is not None: + dtstart = dtstart.value + if not isinstance(dtstart, datetime): + dtstart_is_datetime = False + # TODO: changing dates to datetimes may be wrong because of tz + dtstart = datetime.combine(dtstart, datetime.min.time()).replace( + tzinfo=timezone.utc) + else: + dtstart_is_datetime = True + + + if dtstart_is_datetime: + # Line 1 + return start <= dtstart and end > dtstart + else: + # Line 2 + return start < dtstart + timedelta(days=1) and end > dtstart + + else: + # Line 3 + return False + return True