ozboomer has asked for the wisdom of the Perl Monks concerning the following question:

(..."Internet Calendaring"!? *Ugh* What a mouthful...)

I have an Android smartphone and I use MyPhoneExplorer ("MPE") on a Windows 8 desktop to manipulate the calendar(s) in the phone.

A feature of MPE is that it can export the calendar data in a few formats, being:-

I have no knowledge of processing these formats... and so, I'm looking for some pointers on how I might approach dealing with the requirements I have to process this data.

I'm hoping it makes sense to do something like:-

Magic_Processing(input_file, events_structure) for date is startdate to enddate if exists events_structure{date} event_detail = events_structure{date} further_process(date, event_detail) endif endfor

...where Magic_Processing() is "aware" of the different types of events so the pseudocode I've shown actually works. This means the function would understand about:-

...or something like that.

Simplified, I have a lot of repeating events... and I want to be able to specify a date range and have all the repeating events that will occur in that date range added to a list. Looking at the exported files, entries like:

RRULE:FREQ=MONTHLY;BYDAY=2SA;INTERVAL=6
(in an .ics file) are sort-of meaningless, straight off the bat.

I understand RFC 5545 and possibly RFC 3283 are (probably?) the documents I should attack (at least, for the .ics files, which seem sort of the "most often seen"(!?))... but dealing with detailed RFCs like that is like trying to read microfilm through a mud-filled beer bottle to me... hence this request for some pointers on where to start.

(Apologies if this is sacrilege to write in the Monastery) ...even if there's some Python code I could examine which would give some clues (as I'm trying to learn this language at present)...

Thanks a heap for any thoughts or pointers.

  • Comment on How to Extract Calendar Events in a Specified Date Range from 'Internet Calendaring' (.vcs, .ics) Files
  • Select or Download Code

Replies are listed 'Best First'.
Re: How to Extract Calendar Events in a Specified Date Range from 'Internet Calendaring' (.vcs, .ics) Files
by Corion (Patriarch) on Dec 15, 2018 at 08:57 UTC

    Reading and writing .ics / ICAL data is somewhat less painful when I do it through Data::ICal and Date::ICal (yes, great names ...).

    Unrolling the recurrence rules seems to be available in Net::ICal::Recurrence, so maybe that is enough already for you to handle these.

    Specifying a range and getting all events in that is something that I offloaded to my ICal / CalDAV server (via Net::CalDAVTalk) , which has the API already for such queries), but if you want to roll your own, likely DateTime::Event::ICal has the API you want to get dates out of recurrence lists.

Re: How to Extract Calendar Events in a Specified Date Range from 'Internet Calendaring' (.vcs, .ics) Files
by ozboomer (Friar) on Dec 18, 2018 at 07:54 UTC

    Ok, I've managed to get something sort-of happening now... at least, it will let me get moving on my project... even if! it looks a bit ugly (I don't really know of any other way to deal with non-existent elements of the structures.. .*erk*). I understand that this code doesn't extract info about the alarms and "Sub-Eentires" but I'm not worried about that.

    The code:-

    ...and some sample output:-

    Required Date Range: 01-09-2018 through 31-12-2018 Total Events: 5 ------------------------------------------------------------ Event: 0 Summary: BIRTHDAY: Fred Nurk Start Date: 22-10-2008 End Date: 22-10-2008 Description: 1953 Repeats: FREQ=YEARLY;INTERVAL=1 Sub-Entries: None Location: 2008 ------------------------------------------------------------ Event: 1 Summary: Father's Day Start Date: 07-09-1997 End Date: 07-09-1997 Description: None Repeats: FREQ=MONTHLY;BYDAY=1SU;INTERVAL=12 Sub-Entries: None Location: None ------------------------------------------------------------ Event: 2 Summary: *Work: Trivia Notes... Start Date: 17-12-2018 End Date: 17-12-2018 Description: -info 1 -info 2 -info 3 Repeats: None Sub-Entries: None Location: None ------------------------------------------------------------ Event: 3 Summary: Android: Purge Calendar Events Start Date: 04-03-2001 End Date: 04-03-2001 Description: None Repeats: FREQ=MONTHLY;BYDAY=1SU;INTERVAL=2 Sub-Entries: None Location: None ------------------------------------------------------------ Event: 4 Summary: Take Out Rubbish Bin Start Date: 23-01-2002 End Date: 23-01-2008 Description: None Repeats: FREQ=WEEKLY;BYDAY=WE;INTERVAL=2 Sub-Entries: Exist Location: None OUTPUT ---------------------------------------- 2018-09-02: 1,3 2018-09-12: 4 2018-09-26: 4 2018-10-10: 4 2018-10-22: 0 2018-10-24: 4 2018-11-04: 3 2018-11-07: 4 2018-11-21: 4 2018-12-05: 4 2018-12-19: 4

    It took me a long time to get my head around 'sets' and the DateTime items and how the 'recurrence' works... but I now have something that I think will work.

    As always, I appreciate the pointers... and the clues about something more about Perl that turns out to be very useful to know :)

    Fanx! again.