Skip to content

Instantly share code, notes, and snippets.

@afragen
Created June 8, 2012 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afragen/2893002 to your computer and use it in GitHub Desktop.
Save afragen/2893002 to your computer and use it in GitHub Desktop.
Fix the endDate in ECP iCal feed.
<?php
//Add to theme functions.php
add_filter( 'tribe_ical_feed_item', 'tribe_ical_fix_endDate', 10, 2 );
function tribe_ical_fix_endDate( $item, $eventPost ) {
$searchValue = "DTEND;VALUE";
$fl_array = preg_grep('/^' . "$searchValue" . '.*/', $item);
$key = array_values($fl_array);
$keynum = key($fl_array);
$strlen = strlen($key[0]);
if ( $strlen > 30 ) {
$mod = substr($key[0], 0, -2);
$mod = str_pad( $mod, $strlen, "0" );
unset($item[$keynum]);
$dstart = array_shift($item);
array_unshift($item, $mod);
array_unshift($item, $dstart);
}
return $item;
}
?>
@afragen
Copy link
Author

afragen commented Jun 8, 2012

ECP generated iCal feed seems to add 59 secs to end date for events. This will fix it.

@afragen
Copy link
Author

afragen commented Jun 9, 2012

Added code to rearrange $items array to original order, it looks nicer but not sure it has different functionality.

@afragen
Copy link
Author

afragen commented Jul 17, 2012

Fixed in TEC v2.0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment