Beispiel #1
0
    def test_recurring_component(self):
        vevent = RecurringComponent(name='VEVENT')

        # init
        self.assertTrue(vevent.isNative)

        # rruleset should be None at this point.
        # No rules have been passed or created.
        self.assertEqual(vevent.rruleset, None)

        # Now add start and rule for recurring event
        vevent.add('dtstart').value = datetime.datetime(2005, 1, 19, 9)
        vevent.add('rrule').value =u"FREQ=WEEKLY;COUNT=2;INTERVAL=2;BYDAY=TU,TH"
        self.assertEqual(
            list(vevent.rruleset),
            [datetime.datetime(2005, 1, 20, 9, 0), datetime.datetime(2005, 2, 1, 9, 0)]
        )
        self.assertEqual(
            list(vevent.getrruleset(addRDate=True)),
            [datetime.datetime(2005, 1, 19, 9, 0), datetime.datetime(2005, 1, 20, 9, 0)]
        )

        # Also note that dateutil will expand all-day events (datetime.date values)
        # to datetime.datetime value with time 0 and no timezone.
        vevent.dtstart.value = datetime.date(2005,3,18)
        self.assertEqual(
            list(vevent.rruleset),
            [datetime.datetime(2005, 3, 29, 0, 0), datetime.datetime(2005, 3, 31, 0, 0)]
        )
        self.assertEqual(
            list(vevent.getrruleset(True)),
            [datetime.datetime(2005, 3, 18, 0, 0), datetime.datetime(2005, 3, 29, 0, 0)]
        )
Beispiel #2
0
    def test_recurring_component(self):
        vevent = RecurringComponent(name='VEVENT')

        # init
        self.assertTrue(vevent.isNative)

        # rruleset should be None at this point.
        # No rules have been passed or created.
        self.assertEqual(vevent.rruleset, None)

        # Now add start and rule for recurring event
        vevent.add('dtstart').value = datetime.datetime(2005, 1, 19, 9)
        vevent.add(
            'rrule').value = u"FREQ=WEEKLY;COUNT=2;INTERVAL=2;BYDAY=TU,TH"
        self.assertEqual(list(vevent.rruleset), [
            datetime.datetime(2005, 1, 20, 9, 0),
            datetime.datetime(2005, 2, 1, 9, 0)
        ])
        self.assertEqual(list(vevent.getrruleset(addRDate=True)), [
            datetime.datetime(2005, 1, 19, 9, 0),
            datetime.datetime(2005, 1, 20, 9, 0)
        ])

        # Also note that dateutil will expand all-day events (datetime.date values)
        # to datetime.datetime value with time 0 and no timezone.
        vevent.dtstart.value = datetime.date(2005, 3, 18)
        self.assertEqual(list(vevent.rruleset), [
            datetime.datetime(2005, 3, 29, 0, 0),
            datetime.datetime(2005, 3, 31, 0, 0)
        ])
        self.assertEqual(list(vevent.getrruleset(True)), [
            datetime.datetime(2005, 3, 18, 0, 0),
            datetime.datetime(2005, 3, 29, 0, 0)
        ])
    import sys
    from vobject.icalendar import RecurringComponent, VEvent
    import datetime
    
    app = wx.PySimpleApp()

    for rruleText in sys.argv[1:] or (None,):
        if rruleText:
            rule = rrule.rrulestr(rruleText)
        else:
            rule = None
    
        result = EditRecurrence(rule)
        print 'Result: %s' % (result,)

        if result is not None:
            # Let's use vobject to print out the icalendar form of the
            # rule
            rule = rrule.rrule(**result)
            vobject_event = RecurringComponent()
            vobject_event.behavior = VEvent
            # vobject_event.rruleset will be unhappy if we don't have a
            # dtstart
            vobject_event.add('dtstart').value = datetime.date.today()
            rruleset = rrule.rruleset()
            rruleset.rrule(rule)
            vobject_event.rruleset=rruleset
            # ok, now we're ready to serialize (we strip off the trailing '\r\n')
            output = vobject_event.rrule_list[0].serialize().strip()
            print 'ICS output: %s' % (output,)
    import sys
    from vobject.icalendar import RecurringComponent, VEvent
    import datetime

    app = wx.PySimpleApp()

    for rruleText in sys.argv[1:] or (None, ):
        if rruleText:
            rule = rrule.rrulestr(rruleText)
        else:
            rule = None

        result = EditRecurrence(rule)
        print 'Result: %s' % (result, )

        if result is not None:
            # Let's use vobject to print out the icalendar form of the
            # rule
            rule = rrule.rrule(**result)
            vobject_event = RecurringComponent()
            vobject_event.behavior = VEvent
            # vobject_event.rruleset will be unhappy if we don't have a
            # dtstart
            vobject_event.add('dtstart').value = datetime.date.today()
            rruleset = rrule.rruleset()
            rruleset.rrule(rule)
            vobject_event.rruleset = rruleset
            # ok, now we're ready to serialize (we strip off the trailing '\r\n')
            output = vobject_event.rrule_list[0].serialize().strip()
            print 'ICS output: %s' % (output, )