pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.63k stars 208 forks source link

Crash with events without DTEND #312

Closed fpose closed 8 years ago

fpose commented 8 years ago

Hello,

I am using version 0.7.0 and i am experiencing a crash similar to issue #60. I am trying to import the following ICS (by copying it into the vdir folder):

VERSION:1.0
BEGIN:VEVENT
DTSTART:20151215T064600Z
UID:p-1449942958-16077-13321
SUMMARY:Test entry
END:VEVENT
END:VCALENDAR

I get the following backtrace:

Traceback (most recent call last):
  File "/usr/local/bin/khal", line 9, in <module>
    load_entry_point('khal==0.7.0', 'console_scripts', 'khal')()
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1037, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/khal/cli.py", line 226, in cli
    ctx.invoke(cli.commands[command])
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/khal/cli.py", line 254, in calendar
    full=full
  File "/usr/local/lib/python2.7/site-packages/khal/controllers.py", line 149, in calendar
    show_all_days=show_all_days, full=full, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/khal/controllers.py", line 122, in get_agenda
    items = event.relative_to(day, full).splitlines()
  File "/usr/local/lib/python2.7/site-packages/khal/khalendar/event.py", line 374, in relative_to
    if self.start_local < day_start:
  File "/usr/local/lib/python2.7/site-packages/khal/khalendar/event.py", line 486, in start_local
    return self.start.astimezone(self._locale['local_timezone'])
  File "/usr/local/lib/python2.7/site-packages/khal/khalendar/event.py", line 473, in start
    return self._locale['default_timezone'].localize(self._start)
  File "/usr/lib/python2.7/site-packages/pytz/tzinfo.py", line 303, in localize
    if dt.tzinfo is not None:
AttributeError: 'datetime.date' object has no attribute 'tzinfo'

If I place a DTEND entry in the ICS file, the problem is gone. But missing DTEND is perfectly valid acc. to RFC 5545.

If I can provide any further help with resolving this, I will glady do.

Thanks an regards, Florian

geier commented 8 years ago

Thank you for reporting this.

The issue is the following:

I previously decided to treat events without DTEND as floating events lasting the whole day (all-day events), even if they are localized datetime events, see #84.

Since version 0.7 we support properly support localized and floating events, but I forgot about this special case and those events are at the moment treated as (localized) datetime events, but with dates as start and end, which than leads to the confusion about the missing tzinfo attribute.

I'll need to think about how to best approach this problem.