Jump to content


Photo

Upcoming Calendar Events Can Be 1 Day Out


/admin/applications_addon/ips/calendar/sources/hooks.php

	if ( !$u['event_recurring'] AND ( ( $u['_end_time'] >= $our_unix AND $u['_start_time'] <= $max_date )
	 OR ( !$u['_end_time'] AND $u['_start_time'] >= $our_unix AND $u['_start_time'] <= $max_date ) ) )
	{
	 if( $u['_end_time'] )
	 {
	  while( $u['_start_time'] < time() )
	  {
	   $u['_start_time'] += 86400;
	  }
	 }
	 $events[ str_pad( $u['_start_time'].$u['event_id'], 15, "0" ) ] = $u;
	}

I assume this code is so events on the same day still show even if the event start time has passed? The trouble is, by adding a whole day, the event can be pushed into the following day causing the date to show incorrectly. It looks like we need to add enough time so it still shows but not enough to push it over into the next day. If my assumption is correct the following should fix but feels hacky.

$u['_start_time'] += gmmktime( 0, 0, 0, $month, $day+1, $year) - time();

Ticket #774922 if an example is needed

Status: Fixed
Version: 3.2.1
Fixed In: 3.3.0


2 Comments

Yes, your suspicion is right. We add a day inside the loop until we reach "now". We could probably do this with small increments than 24 hours to minimize the risk of falling over to the next day. Also, time() is not what we use elsewhere throughout Calendar, and may be part of the problem.
Think I got this fixed, but went another route. There's no need to increment anything in a loop best I can see - we just want to bring start time up to current time basically, so I did this instead

if( $u['_end_time'] )
                    {
                        if( $u['_start_time'] < gmmktime( 0 ) )
                        {
                            $u['_start_time']    = gmmktime( 0 );
                        }
                    }

Testing locally it seems ok so far.