[icalendar-dev] feature suggestion & patch

Matt Chisholm matt-icalendar at mosuki.com
Tue Nov 28 21:48:13 CET 2006


Congratulations on the 1.1 / 1.2 releases.  I sent in this patch a
while back, and I see that it hasn't been merged.  Did it get left out
accidentally or on purpose?

If you think it's not worth merging, that's fine with me.  It's not
really that important.  :) I just wanted to make sure it didn't get
left out accidentally.

-matt

On Nov  5 2006, 22:27, Matt Chisholm wrote:
>Hi all.  I'm using the icalendar package to convert iCalendar files
>into an internal database that's not too different than iCalendar.
>
>Any program that wants to calculate recurring event dates basically
>has to perform the parsing done in vWeekday.__init__() in prop.py on
>'BYDAY' fields of 'RRULE' properties.  This method uses the regular
>expression WEEKDAY_RULE to turn strings like '1SU' or '-2FR' into
>structured representations that mean repetitions like "first sunday"
>or "second to last friday".
>
>Rather than duplicate this work internally in our program, it seems to
>make more sense to modify the vWeekday object to store the results of
>this parsing.  The value has to be parsed to make sure it's valid
>iCalendar format anyway, but vWeekday.__init__() throws away the
>results of the parse.
>
>So, here's a patch that modifies vWeekday.__init__() to store the
>results of parsing the string values of BYDAY fields on the vWeekday
>object.
>
>-matt
>

>Index: src/icalendar/prop.py
>===================================================================
>--- src/icalendar/prop.py	(revision 34254)
>+++ src/icalendar/prop.py	(working copy)
>@@ -754,7 +754,12 @@
>         relative = match['relative']
>         if not weekday in vWeekday.week_days or sign not in '+-':
>             raise ValueError, 'Expected weekday abbrevation, got: %s' % self
>+        self.weekday_number = vWeekday.week_days[weekday]
>         self.relative = relative and int(relative) or None
>+        if self.relative:
>+            self.offset_number = int(relative)
>+            if sign == '-':
>+                self.offset_number *= -1
>         self.params = Parameters()
> 
>     def ical(self):

>_______________________________________________
>icalendar-dev mailing list
>icalendar-dev at codespeak.net
>http://codespeak.net/mailman/listinfo/icalendar-dev


 LocalWords:  py


More information about the icalendar-dev mailing list