Help Needed with Calendar Plugin

Hey all! First time posting here. I found a great calendar plugin for Wordpress but there is one bug where I need some help addressing (the plugin developer hasn’t responded in over a week so I thought I’d try here).

Basically the calendar is miscalculating the number of days for an event. For example, if I set an event starting on Nov. 19 and select 7 days, it should show on the calendar and the last day should be Nov. 25. That part is correct but if I click on the event-title, it brings up an event page that lists the title and event dates however the ending date is incorrect (it’s showing Nov. 26, which would be the 8th day).

I attached the PHP code as a txt file but I’m PHP-illiterate and don’t know where to look to fix this miscalculation. Can someone help me troubleshoot this issue?


event-list-cal.txt (64.8 KB)

Just wondering what you get when you add

19
+7

Cause I get 26, which means the plugin is taking the date, plus the days for the length and adding them, making it correct. If you want to include the starting date, which isn’t normal, you need to adjust the length of days for the event.

Good point, but another way of stating the issue is that on the main calendar view the plugin DOES include the starting date whereas it does NOT include that date when you bring up the individual event details. The inconsistency is the issue here, so I need some help figuring out how to correct that issue.

I can’t tell you for sure, because I am not seeing any comments or anything else. I would test this section:
[php]
if( $month == 1 ) {
if( $event_year == ( $year - 1 ) && $event_month == 12 && ! empty( $event_days ) ) {
$num_days_prev_month = date( ‘t’, mktime( 0, 0, 0, $month, 1, ( $year - 1 ) ) );

    if( $event_days > ( $num_days_prev_month - $event_day ) ) {
      
      $days_to_go = abs( $num_days_prev_month - $event_day - $event_days + 1 );
      for( $i = 1; $i <= $days_to_go; $i ++  ) {
        $new_date = ( $year . "-" . $month . "-" . $i );
        $events[] = $event_link . "==" . strtotime( $new_date ) . "==" . $event_time . "==" . $event_excerpt . "==0==0";
      }
    }
  }
} else {
  if( $event_year == $year && $event_month == ( $month - 1 ) &&  ! empty( $event_days ) ) {
    $num_days_prev_month = date( 't', mktime( 0, 0, 0, ( $month - 1 ), 1, $year ) );
    
    if( $event_days > ( $num_days_prev_month - $event_day ) ) {
      
      $days_to_go = abs( $num_days_prev_month - $event_day - $event_days + 1 );
      for( $i = 1; $i <= $days_to_go; $i ++  ) {
        $new_date = ( $year . "-" . $month . "-" . $i );
        $events[] = $event_link . "==" . strtotime( $new_date ) . "==" . $event_time . "==" . $event_excerpt . "==0==0";
      }
    }
  }
}[/php]

And modify the $days_to_go value to see what happens.

Thanks astonecipher! I don’t even know where to begin with modifying this code, but I will do some research and see if I can figure it out. If anyone else has tips on what to modify, I’m all ears!

Sponsor our Newsletter | Privacy Policy | Terms of Service