I noticed earlier this week that I had duplicate "todays" (see attached screenshot).

I was able to resolve this issue by replacing the following code in calendar_block.module

    if ($calendar->day && $date->day == $calendar->day) {
      $class .= ' today';
    }

with this:


    if ( ($calendar->day == $date->day) && ($calendar->month == $date->month) ) {
      $class .= ' today';
    }
CommentFileSizeAuthor
#5 broken.jpg19.46 KBusa2k
#5 unbroken.jpg19.09 KBusa2k
duplicate_today.png12.48 KBjmstacey

Comments

jmstacey’s picture

Title: Duplicate today's » Multiple todays

I haven't run through the code yet, but this change might break cases where the "today" is not on the current month but still viewable. For example, if today was January 1 and the calendar view was on December, January 1 is visible but since it's not on the same month that is viewable it won't be indicated as today. I haven't had time to test it yet.

skilip’s picture

Again, thanks for your report jmstacey! I should make you co-maintainer, if you'd feel like it! I will add your code and test it asap.

kjy07’s picture

Rather than comparing the Calendar Display's month/day to the Day's month/day, compare the Day's month/day to the *current* month/day. This will ensure that multiple "todays" don't appear and also take disabled "todays" into account.

if (($date->month == date('n')) && ($date->day == date('d'))) {
  $class .= ' today';
}
jbomb’s picture

Version: 5.x-2.0 » 6.x-2.2

This is still relevant in the D6 branch. I used the solution provided in #3.

usa2k’s picture

StatusFileSize
new19.09 KB
new19.46 KB

#3 worked for me today on Calendar Block 6.x-2.2