Skip to content

Commit

Permalink
Merge pull request sabre-io#261 from GrahamLinagora/jcal_with_until
Browse files Browse the repository at this point in the history
Fix issue sabre-io#259: add missing date format change in Recur object
  • Loading branch information
evert committed Oct 21, 2015
2 parents 5f675d5 + 3d45bcb commit a1d975e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Property/ICalendar/Recur.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ function setValue($value) {
if (strpos($v, ',') !== false) {
$v = explode(',', $v);
}
if (strcmp($k, 'until') === 0) {
$v = strtr($v, [':' => '', '-' => '']);
}
} else {
$v = array_map('strtoupper', $v);
}
Expand Down
21 changes: 21 additions & 0 deletions tests/VObject/Issue259Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Sabre\VObject;

class Issue259Test extends \PHPUnit_Framework_TestCase {

function testParsingJcalWithUntil() {
$jcalWithUntil = '["vcalendar",[],[["vevent",[["uid",{},"text","dd1f7d29"],["organizer",{"cn":"robert"},"cal-address","mailto:robert@robert.com"],["dtstart",{"tzid":"Europe/Berlin"},"date-time","2015-10-21T12:00:00"],["dtend",{"tzid":"Europe/Berlin"},"date-time","2015-10-21T13:00:00"],["transp",{},"text","OPAQUE"],["rrule",{},"recur",{"freq":"MONTHLY","until":"2016-01-01T22:00:00Z"}]],[]]]]';
$parser = new Parser\Json();
$parser->setInput($jcalWithUntil);

$vcalendar = $parser->parse();
$eventAsArray = $vcalendar->select('VEVENT');
$event = reset($eventAsArray);
$rruleAsArray = $event->select('RRULE');
$rrule = reset($rruleAsArray);
$this->assertNotNull($rrule);
$this->assertEquals($rrule->getValue(), 'FREQ=MONTHLY;UNTIL=20160101T220000Z');
}

}

0 comments on commit a1d975e

Please sign in to comment.