public static function date_ical_plugin_style_ical_feed::convert_rrule_for_icalcreator in Date iCal 7.2
This function converts 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_plugin_style_ical_feed::convert_rrule_for_icalcreator()
- date_ical_plugin_style_ical_feed::render in includes/
date_ical_plugin_style_ical_feed.inc - Render the display in this style.
File
- includes/
date_ical_plugin_style_ical_feed.inc, line 406 - Views style plugin for the Date iCal module.
Class
- date_ical_plugin_style_ical_feed
- Default style plugin to render an iCal feed.
Code
public static function 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, so it's easy to
// split off the ordwk part, even though it could be 1 or 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;
}