Skip to content

Commit

Permalink
Allow for trailing ; in RRULE (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
tacman committed Apr 14, 2022
1 parent 9db156d commit 169666d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ICal/ICal.php
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ protected function processRecurrences()

// Separate the RRULE stanzas, and explode the values that are lists.
$rrules = array();
foreach (explode(';', $anEvent['RRULE']) as $s) {
foreach (array_filter(explode(';', $anEvent['RRULE'])) as $s) {
list($k, $v) = explode('=', $s);
if (in_array($k, array('BYSETPOS', 'BYDAY', 'BYMONTHDAY', 'BYMONTH', 'BYYEARDAY', 'BYWEEKNO'))) {
$rrules[$k] = explode(',', $v);
Expand Down
21 changes: 20 additions & 1 deletion tests/rfc5545RecurrenceExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* The following tests are based on the event recurrence examples given
* in the RFC5545 iCal specification (https://tools.ietf.org/html/rfc5545,
* in the RFC5545 iCal specification (https://datatracker.ietf.org/doc/html/rfc5545,
* pages 123 to 132).
*
* Whilst this might not catch edge-cases, it does give a basic set of
Expand Down Expand Up @@ -101,6 +101,25 @@ public function test_page123_test2()
);
}

// Page 123, Test 3 :: Daily, until December 24th, with trailing semicolon
public function test_page123_test3()
{
$checks = array(
array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
array('index' => 1, 'dateString' => '19970903T090000', 'message' => '2nd occurrence: '),
array('index' => 2, 'dateString' => '19970904T090000', 'message' => '3rd occurrence: '),
);
$this->assertVEVENT(
'America/New_York',
array(
'DTSTART;TZID=America/New_York:19970902T090000',
'RRULE:FREQ=DAILY;UNTIL=19971224T000000Z;',
),
113,
$checks
);
}

// Page 124, Test 1 :: Daily, every other day, Forever
//
// UNTIL rule does not exist in original example
Expand Down

0 comments on commit 169666d

Please sign in to comment.