Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong recurrence handling #196

Closed
pikim opened this issue Dec 3, 2018 · 6 comments
Closed

Wrong recurrence handling #196

pikim opened this issue Dec 3, 2018 · 6 comments

Comments

@pikim
Copy link

pikim commented Dec 3, 2018

  • PHP Version: 7.2.10
  • PHP Default timezone: UTC
    • PHP date.timezone: no value
  • ICS Parser Version: 2.1.7
  • Linux

Description of the Issue:

When I load the attached file, ics-parser gives me 6 events:

  • dtstart: "20191105T190000"
    "rrule": "FREQ=DAILY;UNTIL=20191111T180000Z"
  • dtstart: "20191106T190000"
    "rrule": "FREQ=DAILY;UNTIL=20191111T180000Z"
  • dtstart: "20191107T190000"
    "rrule": "FREQ=DAILY;UNTIL=20191111T180000Z"
  • dtstart: "20191108T190000"
    "rrule": "FREQ=DAILY;UNTIL=20191111T180000Z"
  • dtstart: "20191109T170000"
    "recurrence_id": "20191109T190000"
  • dtstart: "20191110T180000"
    "recurrence_id": "20191110T190000"

When I parse this I get the event 2 times on the 6th, 3 times on the 7th, 4 times on the 8th and so on.

Steps to Reproduce:

Rename test.txt to *.ics and load it with:

$ical_file = "path/to/file";
$ical = new ICal(
    $ical_file,
    array(
        'defaultSpan'                 => 2,     // Default value
        'defaultTimeZone'             => 'UTC',
        'defaultWeekStart'            => 'MO',  // Default value
        'disableCharacterReplacement' => false, // Default value
        'filterDaysAfter'             => null,  // Default value
        'filterDaysBefore'            => null,  // Default value
        'replaceWindowsTimeZoneIds'   => false, // Default value
        'skipRecurrence'              => false, // Default value
        'useTimeZoneWithRRules'       => false, // Default value
    )
);
$events = $ical->sortEventsWithOrder($ical->events());
@u01jmg3 u01jmg3 self-assigned this Dec 30, 2018
@u01jmg3
Copy link
Owner

u01jmg3 commented Jan 2, 2019

When I parse this I get the event 2 times on the 6th, 3 times on the 7th, 4 times on the 8th and so on.

Thanks for raising an issue. Can you confirm what is the expected output versus the actual? i.e. spell out what is wrong with what you are seeing

@pikim
Copy link
Author

pikim commented Jan 9, 2019

Can you confirm what is the expected output versus the actual? i.e. spell out what is wrong with what you are seeing

As I wrote above I'm getting one event starting at 20191105T190000 and ending at 20191111T180000Z, another event starting at 20191106T190000 and ending at the 20191111T180000Z, another event starting at 20191107T190000 and ending at the 20191111T180000Z, and another event starting at 20191108T190000 and ending at the 20191111T180000Z.

As a result I have the event once on the 5th, twice on the 6th, three times on the 7th, four times on the 8th, and so on.

I would expect to get either one event for each day without any rrule or one event starting at the first (5th) day and ending at the last day (8th). Handling the other two days (9th & 10th) separately makes sense as they differ from the others.

@hubermat
Copy link
Contributor

hubermat commented Mar 15, 2019

Basically everything is okay, the ics-parser reads the file correctly and returns the right events in $events. See the unit test that I created for this case.

The problem occurs, if you then try to re-parse the generated events again, as each generated event is marked as belonging to a recurrence, but is then interpreted as a recurrence of its own. But I currently don't see why you would re-parse the events again, if you already have the single events.

@u01jmg3 u01jmg3 added the has-pr label Mar 23, 2019
@pikim
Copy link
Author

pikim commented Mar 24, 2019

But I'm pretty sure that I parse the file only once. Please see the original issue description.

@hubermat
Copy link
Contributor

You wrote: "When I load the attached file, ics-parser gives me 6 events: ..."
Those are the correctly parsed event. All fine.

Then you wrote: "When I parse this I get the event 2 times on the 6th, 3 times on the 7th, 4 times on the 8th and so on."
=> there is no need to "parse this"! The 6 events you got from the ics-parser in the first place is already all you need.

u01jmg3 added a commit that referenced this issue Mar 28, 2019
@u01jmg3 u01jmg3 added this to the v2.x.x milestone Mar 28, 2019
@u01jmg3 u01jmg3 closed this as completed Mar 28, 2019
@u01jmg3 u01jmg3 removed their assignment May 12, 2019
@sherpadawan

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants