[BUG] todo.duration raises error if dtstart is missing
Describe the bug
While an event should have a dtstart, there is no such requirement for a task - and it may make perfect sense to give a task a duration (a time estimate) without giving a dtstart. However, task.duration currently yields an error
To Reproduce
text
from icalendar import Todo
from datetime import timedelta
my_task = Todo.from_ical("""BEGIN:VTODO
UID:taskwithoutdtstart
DTSTAMP:20070313T123432Z
DURATION:P5D
SUMMARY:This is a task that is expected to take five days to complete
STATUS:NEEDS-ACTION
END:VTODO""")
assert(my_task.duration == timedelta(days=5))
Output:
text
Traceback (most recent call last):
File "/tmp/foobar.py", line 12, in <module>
assert(my_event.duration == timedelta(days=5))
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/icalendar/cal.py", line 1077, in duration
return self.end - self.start
^^^^^^^^
File "/usr/lib/python3.13/site-packages/icalendar/cal.py", line 1062, in end
raise IncompleteComponent("No DUE or DURATION+DTSTART given.")
icalendar.error.IncompleteComponent: No DUE or DURATION+DTSTART given....
Expected behavior
my_task.duration should return 5 days.
Additional context
commit d543e2c in the caldav project currently breaks
text
$ pytest -k testTodoDuration
(...)
FAILED test_caldav_unit.py::TestCalDAV::testTodoDuration - icalendar.error.IncompleteComponent: No DUE or DURATION+DTSTART given.