Deal with events that have a DTEND before DTSTART
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.1k
- Forks
- 233
- Avg merge
- 1h 44m
- Merged PRs (30d)
- 1
Description
Do to a bug in gnome-calendar I have multiple events that have a DTEND before DTSTART.
When I run khal I see this exception (though khal seems to work fine afterwards):
Unknown exception happened.
Traceback (most recent call last):
File "/home/varac/.local/venvs/khal/lib/python3.5/site-packages/khal/khalendar/khalendar.py", line 303, in _update_vevent
update(event.raw, href=href, etag=etag, calendar=calendar)
File "/home/varac/.local/venvs/khal/lib/python3.5/site-packages/khal/khalendar/backend.py", line 259, in update
for vevent in sorted(vevents, key=sort_key):
File "/home/varac/.local/venvs/khal/lib/python3.5/site-packages/khal/khalendar/backend.py", line 252, in <genexpr>
c in ical.walk() if c.name == 'VEVENT')
File "/home/varac/.local/venvs/khal/lib/python3.5/site-packages/khal/khalendar/utils.py", line 182, in sanitize
dtstart, dtend, duration=vevent.get('DURATION', None))
File "/home/varac/.local/venvs/khal/lib/python3.5/site-packages/khal/khalendar/utils.py", line 214, in sanitize_timerange
raise ValueError('The event\'s end time (DTEND) is older than '
ValueError: The event's end time (DTEND) is older than the event's start time (DTSTART).
warning: Skipping default/67f29c57-673d-49b0-970c-8dd3c46c2f81.ics: The event's end time (DTEND) is older than the event's start time (DTSTART).
warning: This event will not be available in khal.
I would be nice if khal would tolerate these oddities and doesn't complain so loud. My preference would to to show the event with the same DTEND in the calender as DTSTART, instead of not showing them at all.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in khalendar/utils.py at sanitize_timerange, then inspect khalendar/backend.py update and khalendar.py _update_vevent as shown in the traceback. Reproduce the malformed VEVENT and determine how the invalid time range is handled. Done means khal tolerates DTEND before DTSTART, displays the event using the requested fallback, and no longer emits this exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100