VTODO first implementation

This commit is contained in:
Cedric Boscher 2016-06-15 09:56:05 +02:00
parent 40406359e5
commit 7de63f8335

View File

@ -252,7 +252,60 @@ def _time_range_match(vobject_item, filter_, child_name):
return start < dtstart + timedelta(days=1) and end > dtstart return start < dtstart + timedelta(days=1) and end > dtstart
elif child_name == "VTODO": elif child_name == "VTODO":
# TODO: implement this # TODO: implement this
pass dtstart = getattr(child, "dtstart", None)
duration = getattr(child, "duration", None)
due = getattr(child, "due", None)
completed = getattr(child, "completed", None)
created = getattr(child, "created", None)
if dtstart is not None and duration is not None:
#Line 1
dtstart = dtstart.value
if not isinstance(dtstart, datetime):
dtstart = datetime.combine(dtstart, datetime.min.time()).replace(
tzinfo=timezone.utc)
duration = duration.value
return start <= dtstart + duration and ( end > dtstart or end >= dtstart + duration)
elif dtstart is not None and due is not None:
#Line 2
dtstart = dtstart.value
if not isinstance(dtstart, datetime):
dtstart = datetime.combine(dtstart, datetime.min.time()).replace(
tzinfo=timezone.utc)
due = due.value
if not isinstance(due, datetime):
due = datetime.combine(due, datetime.min.time()).replace(
tzinfo=timezone.utc)
return (start < due or start <= dtstart) and ( end > dtstart or end >= due)
elif dtstart is not None
#Line 3
dtstart = dtstart.value
if not isinstance(dtstart, datetime):
dtstart = datetime.combine(dtstart, datetime.min.time()).replace(
tzinfo=timezone.utc)
return start <= dtstart and end > dtstart
elif due is not None:
#Line 4
due = due.value
if not isinstance(due, datetime):
due = datetime.combine(due, datetime.min.time()).replace(
tzinfo=timezone.utc)
return start < due and end >= due
elif completed is not None and created is not None:
#Line 5
completed = completed.value
created = created.value
return (start <= created or start <= completed) and (end >= created or end >= completed)
elif completed is not None:
#Line 6
completed = completed.value
return start <= completed and end >= completed
elif created is not None:
created = created.value
return end < created
else
return True
elif child_name == "VJOURNAL": elif child_name == "VJOURNAL":
# TODO: implement this # TODO: implement this
pass pass