Skip to content

Commit

Permalink
Fix bug causing the EXDATE property to be ignored when importing events
Browse files Browse the repository at this point in the history
  • Loading branch information
campbell-m committed Sep 4, 2023
1 parent 3ac44ba commit 9f67e8a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions web/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ function get_room_id($location, &$error)
}


// Turn an EXDATE property into an array of timestamps
function get_skip_list(string $values, array $params) : array
{
$result = array();

$tzid = $params['TZID'] ?? 'UTC';
$date_time_zone = new \DateTimeZone($tzid);
$exdates = explode(',', $values);

foreach ($exdates as $exdate)
{
$date = new DateTime($exdate, $date_time_zone);
$result[] = $date->getTimestamp();
}

return $result;
}

// Get the next line, after unfolding, from the stream.
// Returns FALSE when EOF is reached
function get_unfolded_line($handle)
Expand Down Expand Up @@ -364,6 +382,10 @@ function process_event(array $vevent)
}
break;

case 'EXDATE':
$booking['skip_list'] = get_skip_list($details['value'], $details['params']);
break;

case 'CLASS':
$booking['private'] = in_array($details['value'], array('PRIVATE', 'CONFIDENTIAL'));
break;
Expand Down

0 comments on commit 9f67e8a

Please sign in to comment.