[icalendar-dev] Bug in vDuration?
Ferry Boender
ferry.boender at gmail.com
Mon May 12 18:25:15 CEST 2008
Hi All,
(I wonder if this list is still active, but we'll see).
Either I don't fully understand how vDuration should work, or there is a bug
(or rather a shortcoming) in it. When loading a iCalendar file created by
KOrganizer, the alarms are mutilated. Here's an short example of what is
happening which I think isn't correct:
>>> vDuration(timedelta(days=-1)).ical() # Correct
'-P1D'
>>> vDuration(timedelta(days=1, hours=5)).ical() # Correct
'P1DT5H'
>>> vDuration(timedelta(hours=-5)).ical() # Incorrect?
'-P1DT19H'
I would have expected this to render as '-PT15H', which is the way how
KOrganizer marshals negative time offsets for alarms. So now, when I load a
iCal file generated by KOrganizer and write it back again, all the alarms
are FUBAR. It would appear (from the test-cases mentioned in the docstring
of the vDuration ical() method) the original author of the package failed to
notice that converting anything other than negative days fails. (or I'm just
not getting how this should be used ;-) )
I've written a patch to correct the problem, in case anybody is interested.
With the patch (see attachment, if the lists supports them. Otherwise I'll
repost), the marshalling is as follows:
>>> from icalendar import vDuration
>>> from datetime import timedelta
>>> vDuration(timedelta(days=1, hours=5)).ical()
'P1DT5H'
>>> vDuration(timedelta(hours=-5)).ical()
'-PT5H'
>>> vDuration(timedelta(days=-10, hours=-5, minutes=-40)).ical()
'-P10DT5H40M'
All the old testcases still work correctly after applying the patch.
(PS: I haven't looked at the iCalendar standard to see if the current way
iCalendar python module's marshalling to iCal text is correct and KOrganizer
is at fault here).
Grtz,
Ferry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/icalendar-dev/attachments/20080512/505f60d4/attachment-0001.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: icalendar.patch
Type: text/x-patch
Size: 1373 bytes
Desc: not available
Url : http://codespeak.net/pipermail/icalendar-dev/attachments/20080512/505f60d4/attachment-0001.bin
More information about the icalendar-dev
mailing list