function _date_ical_convert_rrule_for_icalcreator in Date iCal 7.3
Convert an rrule array to the iCalcreator format.
iCalcreator expects the BYDAY element to be an array like this: (array) ( [([plus] ordwk / minus ordwk)], "DAY" => weekday )
But the way that the Date API gives it to us is like this: (array) ( [([plus] ordwk / minus ordwk)]weekday )
1 call to _date_ical_convert_rrule_for_icalcreator()
- date_ical_plugin_style_ical_feed::render in includes/
date_ical_plugin_style_ical_feed.inc - Render the event arrays returned by the row plugin into a VCALENDAR.
File
- ./
date_ical.module, line 466 - Adds ical functionality to Views, and an iCal parser to Feeds.
Code
function _date_ical_convert_rrule_for_icalcreator($rrule) {
$new_rrule = array();
foreach ($rrule as $key => $value) {
if (strtoupper($key) == 'DATA') {
// iCalcreator doesn't expect the 'DATA' key that the Date API gives us.
continue;
}
if (strtoupper($key) == 'UNTIL') {
// iCalcreator expects the 'timestamp' to be array key for UNTIL.
$value['timestamp'] = strtotime($value['datetime']);
}
if (strtoupper($key) == 'BYDAY') {
$new_byday = array();
foreach ($value as $day) {
// Fortunately, the weekday values are always 2 characters.
$weekday = substr($day, -2);
$ordwk = substr($day, 0, -2);
$new_byday[] = array(
$ordwk,
'DAY' => $weekday,
);
}
$value = $new_byday;
}
$new_rrule[$key] = $value;
}
return $new_rrule;
}