ics-parser: Duplicate event for recurring meeting instance exception

  • PHP Version: 5.6.30
  • PHP date.timezone: America/New_York

Description of the Issue:

Duplicate meetings for recurring meetings. This happens on meetings that have single occurrences that have different times.

Steps to Reproduce:

Example iCal from Zimbra. On 20/04/2017 there should be 2x 1 hour meetings at 9:00 and 15:30 14:00. Instead 4x 3x meetings are returned. Two One is a duplicate.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 30 (15 by maintainers)

Commits related to this issue

Most upvoted comments

perhaps documentation about setting your display TZ after calling that function? That could confuse folks who aren’t familiar with DateTime objects if they aren’t consistently returned in the same TZ.

  • Changes made to the README - see PR.
  • Would using $ical->iCalDateToDateTime($event->dtstart_array[3], $forceTimeZone = true) prevent you having to apply the time zone?

I’m assuming that function is preferred over using a Unix timestamp since you changed your example.

  • Yes - there are several limitations when using a Unix timestamp (e.g. https://bugs.php.net/bug.php?id=66836) but these are removed when returning a DateTime object.
  • For backwards compatibility until I move to v3.0.0, iCalDateToUnixTimestamp() will still be available but I would recommend moving to DateTime objects in the meantime.

This is the most complete ical parser I found for PHP.

Appreciate the compliment.


Cast your eye over PR #142 and see what you think - made some final changes to refactor and improve the code I had already written but essentially it achieves the same thing and addresses the issues you raised.

You may see some code that looks repetitive and not as neat as it could be - at this point I don’t want to introduce any breaking changes to the parser but eventually I will bump to v3.0.0 and take the hit.

Makes sense… and it’s easy to switch the default value later. I think the variable name works and I can set it to true for our parsing needs. It corrects all the parsing errors I’ve seen in the last month. This is the most complete ical parser I found for PHP. I’ve tried several, all with different problems.

I like how you extended the class to include the TZ. That’s the part I hadn’t looked closely enough on how you were handling TZ within recurrences; I guess you weren’t. I wasn’t sure how best to implement that either and like your solution.

  • Been through your examples and made numerous changes in a separate branch to correct the issues you found

  • Gist of it is, you can now get the UNIX timestamp you are looking for when iterating through the events using:

    $ical->iCalDateToUnixTimestamp($event->dtstart_array[3], $forceTimeZone = true);
    
  • I have also corrected the logic for matching recurrence events by making the comparison aware of time zone data - goodbye dupes

Updated with a readme … hopefully, illustrates the wrong timestamp set

Thanks for your efforts - your patch actually crashes my SourceTree but opening in an editor I get the gist of your change. Still working on an effective resolution. Hope to have something soon.