Skip to content

Commit

Permalink
Merge branch 'duration0' of https://github.com/ralfbecker/horde into …
Browse files Browse the repository at this point in the history
…ralfbecker-duration0
  • Loading branch information
yunosh committed Jun 27, 2015
2 parents 818d9d5 + 1ab359a commit caad3c8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions framework/Icalendar/lib/Horde/Icalendar.php
Expand Up @@ -1540,6 +1540,10 @@ protected function _exportDuration($value)
$duration .= $value . 'S';
}
}
// duration without time ("P") is NOT valid, append 0 seconds ("T0S")
elseif ($duration === 'P') {
$duration .= 'T0S';
}

return $duration;
}
Expand Down
23 changes: 23 additions & 0 deletions framework/Icalendar/test/Horde/Icalendar/ExportTest.php
Expand Up @@ -221,4 +221,27 @@ public function testTimezone()
$ical->exportVCalendar()
);
}

public function testDuration0()
{
$ical = new Horde_Icalendar;
$vevent = Horde_Icalendar::newComponent('VEVENT', $ical);
$vevent->setAttribute('SUMMARY', 'Testevent');
$vevent->setAttribute('UID', 'XXX');
$vevent->setAttribute('DTSTART', array('year' => 2015, 'month' => 7, 'mday' => 1), array('VALUE' => 'DATE'));
$vevent->setAttribute('DTSTAMP', array('year' => 2015, 'month' => 7, 'mday' => 1), array('VALUE' => 'DATE'));
$vevent->setAttribute('DURATION', 0);
$ical->addComponent($vevent);
$valarm = Horde_Icalendar::newComponent('VALARM', $vevent);
$valarm->setAttribute('TRIGGER', 0, array(
'VALUE' => 'DURATION',
'RELATED' => 'START',
));
$valarm->setAttribute('DESCRIPTION', 'Alarm at event-start');
$vevent->addComponent($valarm);
$this->assertStringEqualsFile(
__DIR__ . '/fixtures/duration0.ics',
$ical->exportVCalendar()
);
}
}
15 changes: 15 additions & 0 deletions framework/Icalendar/test/Horde/Icalendar/fixtures/duration0.ics
@@ -0,0 +1,15 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
SUMMARY:Testevent
UID:XXX
DTSTART;VALUE=DATE:20150701
DTSTAMP;VALUE=DATE:20150701
DURATION:PT0S
BEGIN:VALARM
TRIGGER;VALUE=DURATION;RELATED=START:PT0S
DESCRIPTION:Alarm at event-start
END:VALARM
END:VEVENT
END:VCALENDAR

0 comments on commit caad3c8

Please sign in to comment.