Hi All,<br><br>(I wonder if this list is still active, but we'll see).<br><br>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:<br>
<br>>>> vDuration(timedelta(days=-1)).ical() # Correct<br>'-P1D'<br>>>> vDuration(timedelta(days=1, hours=5)).ical() # Correct<br>'P1DT5H'<br>>>> vDuration(timedelta(hours=-5)).ical() # Incorrect?<br>
'-P1DT19H'<br><br>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 ;-) )<br>
<br>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:<br><br>>>> from icalendar import vDuration<br>
>>> from datetime import timedelta<br>>>> vDuration(timedelta(days=1, hours=5)).ical()<br>'P1DT5H'<br>>>> vDuration(timedelta(hours=-5)).ical()<br>'-PT5H'<br>>>> vDuration(timedelta(days=-10, hours=-5, minutes=-40)).ical()<br>
'-P10DT5H40M'<br><br>All the old testcases still work correctly after applying the patch. <br><br>(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).<br>
<br><br>Grtz,<br><br>Ferry<br><br>