wp-event-manager icon indicating copy to clipboard operation
wp-event-manager copied to clipboard

Bug

Open Priya-Goenka opened this issue 3 years ago • 1 comments

I notice in most of your templates, you use a code construct like this (this one from content-event_listing.php):

There are no conditions under which this will be true becuase your dates include the time. That is why the code always displays end date even when it ends on the same day as it starts. This code never effectively does anything.

You need to remove the time component and compare only the day not the datetime.

Priya-Goenka avatar Mar 15 '21 11:03 Priya-Goenka

Here is how I fixed it....

                <div class="wpem-event-details">
                    <div class="wpem-event-title"><h3 class="wpem-heading-text"><?php echo esc_html(get_the_title()); ?></h3></div>
                    <div class="wpem-event-date-time">
                        <span class="wpem-event-date-time-text">
                            <?php
                            display_event_start_date();
                            if (!empty($start_time)) {
                                display_date_time_separator();
                            }
                            display_event_start_time();
                            if (isset($start_date) && isset($end_date)) {
                            		$test_start_date = date_i18n('Y-m-d', strtotime($start_date));
                            		$test_end_date = date_i18n('Y-m-d', strtotime($end_date));
                             	if ($test_start_date != $test_end_date) {
                             		echo " to "; 
                                	display_event_end_date();
                                	echo " "; //the function should output this!
                                	display_date_time_separator();
                                	echo " "; //the function should output this!
                                	if (!empty($end_date) && !empty($end_time)){
					display_event_end_time();
                                	}
                               }
                            }
                            ?> 
                        </span>
                    </div>

Priya-Goenka avatar Mar 15 '21 11:03 Priya-Goenka