Skip to content

Commit

Permalink
This might be correct strictly to RFC 2445, but it's not like any oth…
Browse files Browse the repository at this point in the history
…er iCalendar implementation seems to do it.
  • Loading branch information
yunosh committed Jun 16, 2014
1 parent fdc8203 commit c95f68e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 20 deletions.
17 changes: 2 additions & 15 deletions kronolith/lib/Event.php
Expand Up @@ -706,12 +706,8 @@ public function toiCalendar($calendar)
}

if ($this->isAllDay()) {
/* DTEND is non-inclusive, but $this->end is inclusive. */
$end = clone $this->end;
$end->sec++;

$vEvent->setAttribute('DTSTART', $this->start, array('VALUE' => 'DATE'));
$vEvent->setAttribute('DTEND', $end, array('VALUE' => 'DATE'));
$vEvent->setAttribute('DTEND', $this->end, array('VALUE' => 'DATE'));
$vEvent->setAttribute('X-FUNAMBOL-ALLDAY', 1);
} else {
$this->setTimezone(true);
Expand All @@ -726,13 +722,8 @@ public function toiCalendar($calendar)
}
}

/* DTEND is non-inclusive, but $this->end is inclusive. This needs
* to be done AFTER setting the timezone. */
$end = clone $this->end;
$end->sec++;

$vEvent->setAttribute('DTSTART', clone $this->start, $params);
$vEvent->setAttribute('DTEND', clone $end, $params);
$vEvent->setAttribute('DTEND', clone $this->end, $params);
}

$vEvent->setAttribute('DTSTAMP', $_SERVER['REQUEST_TIME']);
Expand Down Expand Up @@ -1202,10 +1193,6 @@ public function fromiCalendar($vEvent, $parseAttendees = false)
'month' => (int)$this->end->month,
'mday' => (int)$this->end->mday + 1),
$tzid);
} else {
// Otherwise, honor RFC 2445 that says DTEND is non-inclusive
// (we store it as inclusive).
--$this->end->sec;
}
} else {
// Date field
Expand Down
2 changes: 1 addition & 1 deletion kronolith/test/Kronolith/Integration/FromIcalendarTest.php
Expand Up @@ -38,7 +38,7 @@ public function testStart()
public function testEnd()
{
$event = $this->_getFixture('fromicalendar.ics');
$this->assertEquals('2010-11-01 10:59:59', (string)$event->end);
$this->assertEquals('2010-11-01 11:00:00', (string)$event->end);
}

public function testAllDay()
Expand Down
2 changes: 1 addition & 1 deletion kronolith/test/Kronolith/fixtures/export1.ics
Expand Up @@ -3,7 +3,7 @@ VERSION:1.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
DTSTART:20070315T121020Z
DTEND:20070315T132001Z
DTEND:20070315T132000Z
DTSTAMP:--------T------Z
UID:20070315143732.4wlenqz3edq8@horde.org
SUMMARY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:H=C3=BCbscher Termin
Expand Down
2 changes: 1 addition & 1 deletion kronolith/test/Kronolith/fixtures/export2.ics
Expand Up @@ -3,7 +3,7 @@ VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
DTSTART:20070315T121020Z
DTEND:20070315T132001Z
DTEND:20070315T132000Z
DTSTAMP:--------T------Z
UID:20070315143732.4wlenqz3edq8@horde.org
SUMMARY:Hübscher Termin
Expand Down
2 changes: 1 addition & 1 deletion kronolith/test/Kronolith/fixtures/export3.ics
Expand Up @@ -3,7 +3,7 @@ VERSION:1.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
DTSTART:20070315T121020Z
DTEND:20070315T132001Z
DTEND:20070315T132000Z
DTSTAMP:--------T------Z
UID:20070315143732.4wlenqz3edq8@horde.org
SUMMARY:busy
Expand Down
2 changes: 1 addition & 1 deletion kronolith/test/Kronolith/fixtures/export4.ics
Expand Up @@ -3,7 +3,7 @@ VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
DTSTART:20070315T121020Z
DTEND:20070315T132001Z
DTEND:20070315T132000Z
DTSTAMP:--------T------Z
UID:20070315143732.4wlenqz3edq8@horde.org
SUMMARY:busy
Expand Down

0 comments on commit c95f68e

Please sign in to comment.