Parsing iCal from Outlook: how do I tell what the recurrence schedule is for this event?

时光怂恿深爱的人放手 提交于 2019-12-05 22:50:39

I ran through your ICS file with following program:

from icalendar import Calendar, Event
from datetime import datetime

cal = open('test.ics','rb')
ical = Calendar.from_ical(cal.read())
for component in ical.walk():
    if component.name == 'VEVENT':
        for item in component.sorted_items():

            if item[0] == 'RECURRENCE-ID':
                reoccur_item = item[1]
                print reoccur_item.params
                print reoccur_item.dt
                continue
            if item[0] == 'DTSTART':
                print 'DSTART', item[1].dt
                continue
            if item[0] == 'DTEND':
                print 'DTEND', item[1].dt
                continue
            if item[0] == 'DTSTAMP':
                print 'DTSTAMP', item[1].dt
                continue
            print item

cal.close()

And following is the output that I obtained

('SUMMARY', vText(u'My Cool Event'))
DSTART 2012-03-29 12:00:00
DTEND 2012-03-29 12:30:00
DTSTAMP 2012-04-11 22:09:38+00:00
('UID', vText(u'040000008200E00074C5B7101A82E008000000000029934B3300CD01000000000000000   0100000001516438BA45C3946AF9C4C2A563FB2BE'))
RECURRENCE-ID Parameters({'TZID': 'Eastern Standard Time'})
RECURRENCE-ID 2012-04-19 12:00:00
('SEQUENCE', 8)
('CLASS', vText(u'PUBLIC'))
('CREATED', <icalendar.prop.vDDDTypes instance at 0x101c4e518>)
('DESCRIPTION', vText(u'\n'))
('LAST-MODIFIED', <icalendar.prop.vDDDTypes instance at 0x1020874d0>)
('LOCATION', vText(u'1501 Fake Street, Conference Room G'))
('PRIORITY', 5)
('TRANSP', vText(u'OPAQUE'))
('X-ALT-DESC', vText(u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E   N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ve   rsion 14.02.5004.000">\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted f   rom text/rtf format -->\n\n<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG   ="en-us"></SPAN></P>\n\n</BODY>\n</HTML>'))
('X-MICROSOFT-CDO-BUSYSTATUS', vText(u'BUSY'))
('X-MICROSOFT-CDO-IMPORTANCE', vText(u'1'))
('X-MICROSOFT-DISALLOW-COUNTER', vText(u'FALSE'))
('X-MS-OLK-APPTLASTSEQUENCE', vText(u'16'))
('X-MS-OLK-APPTSEQTIME', vText(u'20120411T220937Z'))
('X-MS-OLK-AUTOFILLLOCATION', vText(u'FALSE'))
('X-MS-OLK-CONFTYPE', vText(u'0'))

The re-occurrence rule is empty and this almost looks like single instance of the re-occuring event but for the various Microsoft specific data in the end. This has sequence number 8 and X-MS-OLK-APPTLASTSEQUENCE:16 suggests that the last instance should have sequence 16.

It almost looks like it has created multiple instances with sequence stamp on each of team with the same UID

did you try exporting the calendar using vba? this might be an option for you to get the rrule. you would have to watch for Item.GetRecurrencePattern (Item being declared as myItem As AppointmentItem) and compare to olRecursMonthly, olRecursYearly, ... then look for the interval and count attributes of your item to rebuild the whole rrule string.

you can find more details at this project: http://sourceforge.net/projects/outlook2ical/files/outlook2ical/v1.04/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!