Set DTSTAMP according to RFC 5545, Section 3.8.7.2.: In the case of an iCalendar object that doesn't specify a 'METHOD' property, this property specifies the date and time [...] the calendar component was last revised

This commit is contained in:
Thomas Bruederli 2013-10-01 11:55:10 +02:00
parent c891f82269
commit 455c52c61f

View file

@ -621,6 +621,7 @@ class libvcalendar
public function export($objects, $method = null, $write = false, $get_attachment = false, $recurrence_id = null) public function export($objects, $method = null, $write = false, $get_attachment = false, $recurrence_id = null)
{ {
$memory_limit = parse_bytes(ini_get('memory_limit')); $memory_limit = parse_bytes(ini_get('memory_limit'));
$this->method = $method;
// encapsulate in VCALENDAR container // encapsulate in VCALENDAR container
$vcal = VObject\Component::create('VCALENDAR'); $vcal = VObject\Component::create('VCALENDAR');
@ -665,7 +666,10 @@ class libvcalendar
$type = $event['_type'] ?: 'event'; $type = $event['_type'] ?: 'event';
$ve = VObject\Component::create($this->type_component_map[$type]); $ve = VObject\Component::create($this->type_component_map[$type]);
$ve->add('UID', $event['uid']); $ve->add('UID', $event['uid']);
$ve->add(self::datetime_prop('DTSTAMP', new DateTime(), true));
// set DTSTAMP according to RFC 5545, 3.8.7.2.
$dtstamp = !empty($event['changed']) && !empty($this->method) ? $event['changed'] : new DateTime();
$ve->add(self::datetime_prop('DTSTAMP', $dtstamp, true));
// all-day events end the next day // all-day events end the next day
if ($event['allday'] && !empty($event['end'])) { if ($event['allday'] && !empty($event['end'])) {