Event icon shows wrong date (yesterday)

Home Forums Calendar Products Events Calendar PRO Event icon shows wrong date (yesterday)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1018034
    golfgt
    Participant

    Hey there,

    I had the problem that the calendar icon in the list view of a todays event was showing yesterdays day and date (e.g. Sunday 25. instead of Monday 26.).

    I had to remove a line in the widgets.php of the events-calendar-pro extension and modify the date.php of the the-events-calendar extension to get it working correctly:

    date.php:

    	/**
    	 * Returns formatted date for the official end of the day according to the Multi-day cutoff time option
    	 *
    	 * @category Events
    	 * @param string $date   The date to find the end of the day, defaults to today
    	 * @param string $format Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
    	 *
    	 * @return string
    	 */
    	function tribe_event_end_of_day( $date = null, $format = 'Y-m-d H:i:s' ) {
    		$multiday_cutoff = explode( ':', tribe_get_option( 'multiDayCutoff', '00:00' ) );
    		$hours_to_add    = $multiday_cutoff[0];
    		$minutes_to_add  = $multiday_cutoff[1];
    
    		if ( is_null( $date ) || empty( $date ) ) {
    			return apply_filters( 'tribe_event_end_of_day', date( $format, strtotime( 'tomorrow  +' . $hours_to_add . ' hours ' . $minutes_to_add . ' minutes' ) - 1 ) );
    		} else {
    			if ($format == 'U') {
    				return apply_filters( 'tribe_event_end_of_day', date( $format, strtotime( date( 'Y-m-d', $date) . ' +1 day ' . $hours_to_add . ' hours ' . $minutes_to_add . ' minutes' ) - 1));
    			} else {
    				return apply_filters( 'tribe_event_end_of_day', date( $format, strtotime( date( 'Y-m-d', strtotime( $date ) ) . ' +1 day ' . $hours_to_add . ' hours ' . $minutes_to_add . ' minutes' ) - 1));
    			}
    		}
    	}

    widget.php

    /**
     * Returns the event date, or today's date if the event has started and is not over yet.
     *
     * @return int
     **/
    function tribe_events_get_widget_event_post_date() {
    	global $post, $wp_query;
    
    	$startDate = strtotime( $post->EventStartDate );
    	$endDate   = strtotime( $post->EventEndDate );
    
    	$is_multiday = tribe_event_is_multiday( $post->ID );
    	$is_all_day = tribe_event_is_all_day( $post->ID );
    
    	$today     = current_time( 'timestamp' );
    	$yesterday = $today - DAY_IN_SECONDS;
    
    	// Gets Yesterday cutoff to check which date we pick
    	$yesterday_end = ( (int) tribe_event_end_of_day( $yesterday, 'U' ) ) + 1;
    
    	// Check if the yesterday cutoff will get the start date of the event
    	if ( $yesterday_end >= $startDate && ! $is_multiday && ! $is_all_day ) {
    		$postDate = $yesterday;
    	// If the event starts way in the past or ends way in the future, let's show today's date
    	} elseif ( $today > $startDate && $today < $endDate ) {
    		$postDate = $today;
    	} else {
    		$postDate = $startDate;
    	}
    
    	/* If the user clicked in a particular day, let's show that day as the event date, even if the event spans a few days */
    	if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] == 'tribe-mini-cal-day' ) {
    		$postDate = strtotime( $_POST['eventDate'] );
    	}
    
    	return apply_filters( 'tribe_events_get_widget_event_post_date', $postDate );
    }

    Maybe you can fix that in a future version?

    #1018076
    Brian
    Member

    Hi,

    I apologize I missed something in QA and we introduced a bug here.

    I see you already fixed it, but here is my fix as well:

    You can replace the contents of this file:

    plugins/events-calendar-pro/src/functions/template-tags/widgets.php

    With the coding here:

    https://gist.githubusercontent.com/jesseeproductions/1bf79bcf1bc3de55ccee/raw/fe1b82fbedd58c55a95bcf9704cfb82e4266bdd9/widget.php

    That will fix the issue until we can release a patch.

    We are working on that patch and at worse it will be out with 4.0.

    Thanks

    #1018690
    golfgt
    Participant

    Thanks for your version of a fix! Works fine for me!

    #1018692
    Brian
    Member

    You’re Welcome.

    I am going to close this ticket to new replies, but the issue is still open and we will update this ticket once we release a fix.

    If you have any new questions or issues please create a new ticket and reference this one.

    Thanks

    #1022346
    Geoff
    Member

    Hey, just chiming in here to let you know that Events Calendar PRO 3.12.6 just released moments ago and includes a patch for this issue. Thanks so much for reporting this and for your patience while we worked on a solution. Feel free to hit us up with a new thread if you continue to see an issue or run into any others and we’d be happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Event icon shows wrong date (yesterday)’ is closed to new replies.