Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Patch against 2.0.10 to only display end time in The Events Calendar widget if end date is equal begin date. (German) example: 4. Februar 2013 19:00 – 22:00 instead of previously 4. Februar 2013 19:00 – 4. Februar 2013 22:00
--- the-events-calendar/public/template-tags/date.php 2012-12-26 13:57:11.000000000 +0100
+++ date.php 2012-12-26 18:32:36.000000000 +0100
@@ -57,7 +57,7 @@
* @todo support $postId for recurring events.
* @since 2.0
*/
- function tribe_get_end_date( $postId = null, $displayTime = 'true', $dateFormat = '' ) {
+ function tribe_get_end_date( $postId = null, $displayTime = 'true', $dateFormat = '', $displayDate = true ) {
$postId = TribeEvents::postIdHelper( $postId );
if (!$postId || ( function_exists('tribe_is_recurring_event') && tribe_is_recurring_event( $postId ) ) ) {
global $post;
@@ -77,7 +77,7 @@
return; // '—';
}
- return tribe_event_format_date($date, $displayTime, $dateFormat );
+ return tribe_event_format_date($date, $displayTime, $dateFormat, $displayDate );
}
/**
@@ -91,11 +91,12 @@
* @return string
* @since 2.0
*/
- function tribe_event_format_date($date, $displayTime = true, $dateFormat = '') {
+ function tribe_event_format_date($date, $displayTime = true, $dateFormat = '', $displayDate = true) {
$tribe_ecp = TribeEvents::instance();
- if( $dateFormat ) $format = $dateFormat;
- else $format = get_option( 'date_format', TribeDateUtils::DATEONLYFORMAT );
+ if( $displayDate )
+ if( $dateFormat ) $format = $dateFormat;
+ else $format = get_option( 'date_format', TribeDateUtils::DATEONLYFORMAT );
if ( $displayTime )
$format = $tribe_ecp->getTimeFormat( $format );
@@ -106,4 +107,4 @@
}
}
-?>
\ Kein Zeilenumbruch am Dateiende.
+?>
--- the-events-calendar/views/events-list-load-widget-display.php 2012-12-26 13:57:11.000000000 +0100
+++ events-list-load-widget-display.php 2012-12-26 18:48:37.493054525 +0100
@@ -44,8 +44,11 @@
$output = '';
echo tribe_get_start_date( $post->ID );
- if( tribe_is_multiday( $post->ID ) || !$event->AllDay ) {
- echo ' – <br/>'. tribe_get_end_date($post->ID);
+ if( tribe_is_multiday( $post->ID ) ) {
+ echo ' – <br/>'. tribe_get_end_date($post->ID, 'true', '', true);
+ }
+ elseif( !$event->AllDay ) {
+ echo ' – '. tribe_get_end_date($post->ID, 'true', '', false);
}
if( $event->AllDay ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment