How to use icalendar - 10 common examples

To help you get started, we’ve selected a few icalendar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Aalto-LeTech / a-plus / course / views.py View on Github external
def get(self, request, *args, **kwargs):
        cal = icalendar.Calendar()
        cal.add('prodid', '-// {} calendar //'.format(settings.BRAND_NAME))
        cal.add('version', '2.0')
        for module in self.instance.course_modules.all():
            event = icalendar.Event()
            event.add('summary', module.name)
            event.add('dtstart',
                module.closing_time - datetime.timedelta(hours=1))
            event.add('dtend', module.closing_time)
            event.add('dtstamp', module.closing_time)
            event['uid'] = "module/" + str(module.id) + "/A+"
            cal.add_component(event)

        return HttpResponse(cal.to_ical(),
            content_type="text/calendar; charset=utf-8")
github jazzband / django-ical / django_ical / tests.py View on Github external
def item_organizer(self, obj):
        organizer_dic = obj.get('organizer', None)
        if organizer_dic:
            if isinstance(organizer_dic, dict):
                organizer = icalendar.vCalAddress('MAILTO:%s' % organizer_dic['email'])
                for key, val in organizer_dic.items():
                    if key is not 'email':
                        organizer.params[key] = icalendar.vText(val)
            else:
                organizer = icalendar.vCalAddress('MAILTO:%s' % organizer_dic)
            return organizer
github pimutils / khal / tests / ui / test_editor.py View on Github external
icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,SU,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=-1SU')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=1,2,3,4,5,6,7')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=-1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=3')
    )
github pimutils / khal / tests / ui / test_editor.py View on Github external
def test_check_understood_rrule():
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=1SU')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYMONTHDAY=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TU,TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,SU,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=-1SU')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=1,2,3,4,5,6,7')
    )
github pimutils / khal / tests / ui / test_editor.py View on Github external
def test_check_understood_rrule():
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=1SU')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYMONTHDAY=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TU,TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,SU,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
github pimutils / khal / tests / ui / test_editor.py View on Github external
def test_check_understood_rrule():
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=1SU')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYMONTHDAY=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TU,TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,SU,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=-1SU')
    )
github pimutils / khal / tests / ui / test_editor.py View on Github external
icalendar.vRecur.from_ical('FREQ=MONTHLY;BYMONTHDAY=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TU,TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,SU,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=-1SU')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=1,2,3,4,5,6,7')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=-1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=3')
    )
github pimutils / khal / tests / ui / test_editor.py View on Github external
icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,SU,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=-1SU')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=1,2,3,4,5,6,7')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=-1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=3')
    )
github pimutils / khal / tests / ui / test_editor.py View on Github external
icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=1SU')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYMONTHDAY=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TU,TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,SU,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=-1SU')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=1,2,3,4,5,6,7')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=-1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=3')
    )
github pimutils / khal / tests / ui / test_editor.py View on Github external
icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TU,TH;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,SU,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;INTERVAL=2;BYDAY=WE,MO,TH,FR,TU,SA;BYSETPOS=1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=-1SU')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=1,2,3,4,5,6,7')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=-1')
    )
    assert not RecurrenceEditor.check_understood_rrule(
        icalendar.vRecur.from_ical('FREQ=MONTHLY;BYDAY=TH;BYSETPOS=3')
    )