def add_all_saints_day(self, year): """Add recurring event for all saint's day.""" event = Holiday(date(year, 1, 1), 'Alla helgons dag') rrule = vRecur() rrule['FREQ'] = vFrequency('YEARLY') rrule['BYDAY'] = vWeekday('SA') rrule['BYMONTHDAY'] = 31 rrule['BYMONTH'] = 10 event.add('rrule', rrule) self.add_component(event) event2 = Holiday(date(year, 1, 1), 'Alla helgons dag') rrule2 = vRecur() rrule2['FREQ'] = vFrequency('YEARLY') rrule2['BYDAY'] = vWeekday('SA') rrule2['BYMONTHDAY'] = (1, 2, 3, 4, 5, 6) rrule2['BYMONTH'] = 11 event2.add('rrule', rrule2) self.add_component(event2)
def add_all_saints_eve(self, year): """Add recurring event for all saint's eve.""" event = Holiday(date(year, 1, 1), 'Allhelgonaafton', Work.DEPENDS) rrule = vRecur() rrule['FREQ'] = vFrequency('YEARLY') rrule['BYDAY'] = vWeekday('FR') rrule['BYMONTHDAY'] = (30, 31) rrule['BYMONTH'] = 10 event.add('rrule', rrule) self.add_component(event) event2 = Holiday(date(year, 1, 1), 'Allhelgonaafton', Work.DEPENDS) rrule2 = vRecur() rrule2['FREQ'] = vFrequency('YEARLY') rrule2['BYDAY'] = vWeekday('FR') rrule2['BYMONTHDAY'] = (1, 2, 3, 4, 5) rrule2['BYMONTH'] = 11 event2.add('rrule', rrule2) self.add_component(event2)
def add_midsummer_day(self, year): """Add recurring event for the midsummer day.""" event = Holiday(date(year, 1, 1), 'Midsommardagen') rrule = vRecur() rrule['FREQ'] = vFrequency('YEARLY') rrule['BYDAY'] = vWeekday('SA') rrule['BYMONTHDAY'] = (20, 21, 22, 23, 24, 25, 26) rrule['BYMONTH'] = 6 event.add('rrule', rrule) self.add_component(event)
def add_midsummers_eve(self, year): """Add recurring event for midsummer's eve.""" event = Holiday(date(year, 1, 1), 'Midsommarafton', Work.DEFACTO) rrule = vRecur() rrule['FREQ'] = vFrequency('YEARLY') rrule['BYDAY'] = vWeekday('FR') rrule['BYMONTHDAY'] = (19, 20, 21, 22, 23, 24, 25) rrule['BYMONTH'] = 6 event.add('rrule', rrule) self.add_component(event)
def set_byday(self, bdays): daypos = kolabformat.vectordaypos() for wday in bdays: if isinstance(wday, str): wday = icalendar.vWeekday(wday) weekday = str(wday)[-2:] occurrence = int(wday.relative) if str(wday)[0] == '-': occurrence = occurrence * -1 if self.weekday_map.has_key(weekday): daypos.append( kolabformat.DayPos(occurrence, self.weekday_map[weekday])) self.setByday(daypos)