This is my first bug report here, so I may be reporting incorrectly.

The issue I have is this: once user clicks on the Year view of a calendar, then when they click on Month or Week or Day, they are not taken to the current month, week, day, but instead they are taken to the last week of the year.

So if the year view shows 2009, Month links to /2009-12, week links to /2009-W50 and day links to /2009-12-09.


Andrew Schulman’s picture


pmusaraj’s picture

Just an update for this issue:

Would the fact that I'm using the Date API with PHP 5.0.1 (and the Date PHP4 module that translates some functions) be a factor? Does this affect the Year, Month, Day links?

Also of note, I'm using now the dev version of Views now, and the issue persists.

arnd’s picture


pmusaraj’s picture

Title:On Year view, links to month, week and day point to December, not current month» Follow-up

Until this gets fixed, I'm implementing a very very short hack. On calendar/theme/ line 24 I am replacing :

$view->date_info->month    = $view->date_info->month && $view->date_info->month != $view->argument['date_argument']->options['wildcard'] ? $view->date_info->month : date_format($now, 'm');


  $view->date_info->month    = date_format($now, 'm');

My line just picks today's date at all times, as the value to be used for the month, year, day, navigation links. It picks current month, and then appends it to the year value of the argument.

Again, this is a hack, and it shouldn't be done, but it helps when you're in a pinch.

pmusaraj’s picture

Title:Follow-up» Year, Month, Week links broken
arnd’s picture

new617 bytes

This patch is meant to show the reason for the problem. It is certainly not a good solution. including the prev and next links into testing and browse through the year/month/week hierarchy one can find more trouble.

leelanorton’s picture

I need a fix that can be used on a live commercial site.

NikLP’s picture

Status:Active» Fixed

Marking this fixed because I'm pretty sure it is. Suggest updating to latest release of course. Works for me in 2.2+

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jimboh’s picture

Status:Closed (fixed)» Active

I have just implemented latest date+calendar (6.x-2.x-dev) on drupal 6.14.
I have this problem.

On entering Calendar page with year view showing 2010. Current date = 2010-01-26 (strong is wrong)

year link is 2010, monthlink is 2010-12 weeklink is 2010-W53 and daylink is 2010-12-26

Update: on further investigation, the links appear to be pretty wierd.

On first entry to the page or if the year link is chosen, its as above.

If click on a date to navigate to day view, the day, week and month links are correct
eg click on 19th May - display is day of may19 -
yearlink is 2010, monthlink is 2010-05 weeklink is 2010-W21 and daylink is 2010-05-19

then click on weeklink -
yearlink is 2010, monthlink is 2010-01 weeklink is 2010-W21 and daylink is 2010-01-26

then click on monthlink - display is Jan
all links are now correct for current date

it will not maintain day/week/month sync

marcushenningsen’s picture

Title:Year, Month, Week links broken» Navigation links (Month, week, and day) sometimes incorrect
Version:6.x-2.0» 5.x-2.2

This is still an issue with version 2.2. I investigated the issue thouroughly, which didn't make it less complicated, but here are my results:

(current date: 2010-03-04)
(chosen date: 2011-07-15 (W28)

Day view:

  • Year links to the year of the chosen day: 2011 (expected)
  • Month links to the month of the chosen day: 2011-07 (expected)
  • Week links to the week of the chosen day: 2011-W28 (expected)
  • Day links to the chosen day:2011-07-15 (expected)

Week view:

  • Year links to the year of the chosen week: 2011 (expected)
  • Month links to the chosen year but the current month:2011-03 (unexpected, should probably be the month in which thursday of the chosen week is present)
  • Week links to the chosen week:2011-W28 (expected)
  • Day links to the chosen year but the current month and day:2011-03-04 (unexpected, should probably be either the first day or thursday of the chosen week, or if the current day is included in the chosen week then the current day)

Month view: 2011-07

  • Year links to the year of the chosen month:2011 (expected)
  • Month links to the chosen month:2011-07 (expected)
  • Week links to the first week (i.e. the week with the month's first thursday) of the chosen month: 2011-W27 (expected)
  • Day links to the chosen year and month but the current day:2011-07-04 (unexpected, should probably be the first day of the chosen month, or if the current day is included in the chosen month then the current day)

Year view: 2011

  • Year links to the chosen year: 2011 (expected)
  • Month links to the last month of the chosen year: 2011-12 (unexpected, should probably be the first month of the year, or if the current month is included in the year then the current month)
  • Week links to the first week of the last month of the chosen year: 2011-W48 (unexpected, should probably be the first week of the year, or if the current week is included in the year then the current week )
  • Day links to current day of the last month of the chosen year:2011-12-04 (unexpected, should probably be the first day of the year, or if the current day is included in the year then the current day)

Now, before digging into the code, I suggest that we (needless to say, in collaboration with the maintainer) agree on what is in fact expected behaviour. The added paranthesis are my ideas of expected and unexpected behaviour, but this of course is due to discussion.

Looking forward to hearing your comments...


marcushenningsen’s picture

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

Sorry, bad version tag.

Gribnif’s picture

My opinions:

Week view:

Month links to the chosen year but the current month:2011-03 (unexpected, should probably be the month in which thursday of the chosen week is present)

I think this should be the month of the first day of the week shown (usually Sunday). The same can be said for the Day link. I really don't like the idea of "today's weekday" affecting which week or day is chosen by these links, as it seems unlikely that any user would guess this as the reason for the behavior.
Month view:
I agree with your suggestion for the Day link.
Year view:
I agree with you.
_vid’s picture

I had the same issue in 6.x-2.2 and updated to dev. Still having the issue.
I noticed it in week view. As stated above the year is correct but the month is the current month. Attached a screenshot.

I agree with marcushenningsen on week view's month link expected behavior.
In fact all recommendations in bold look good.

jenyum’s picture

subscribing. Need a fix for a commercial site.

Edited to say: if we could just get a fix for the year to day link I think that would do the trick. Some of the other behavior might not be what everyone would expect but it does at least make sense.

marcushenningsen’s picture

Status:Active» Needs review
new7.76 KB

Patch attached. Changes according to most of my proposals above, futher explanations can be found in the patch. I've tested it thouroughly, but I'd appreciate if someone else could please review this, too.

janwalhof’s picture

Hello Marcus,

I use drupal 6.16 and Calendar 6x-2.2.

I have tested your patch today with the date april 17th 2010.

Things are better now except for the display of the week. Your patch calculates week 15 with the day-indicator 4th april 2010. Week 15 is correct, in case that week 1, this year, started on the 3th of januari. The day-indicator of the week, 4th of april 2010, is not correct. It should be the 11th of april 2010.

I solved this by changing your statement:
+ $current_week = date_format($now, 'W');
+ $current_week = date_format($now, 'W')+1;

I'm not sure this will still work correct in all circumstances.

Jan Walhof

RedTop’s picture

Thanks guys,

I'm using Drupal 6.16, calendar 6.x-2.2, date 6.x-2.4. Patch seems to work well. I've added Jan's modification.

shark’s picture


gollyg’s picture

Status:Needs review» Needs work

I don't think that #18 is correct - I believe that the issue is that the php week function always uses ISO week numbers, whereas the date module can be configured to use ISO or non-ISO (it is non-ISO by default). Rather than changing the week number, it would be better to change your ISO date configuration at It seems optimistic that adding 1 to the ISO week number will work in all cases - I imagine it just happens to be correct in 2010.

I guess the patch should really check the status of this ISO setting via the variable date_api_use_iso8601 and apply any modifications as necessary, although I am unsure as to how non-ISO week numbers are calculated? I am guessing that week one is the week with the 1st of January. If this is the case I can create a patch to adjust this conditionally.

beauz’s picture

I've just had a similar problem, make sure you check the granularity on the default argument. It should be day and not year.

squiggy’s picture

@beauz, thank you for posting the tip. That fixed this for me with drupal 6.22, date 6.x-2.7 and calendar 6.x-2.4.

manos_ws’s picture

In which view should the granularity should be fixed ?

I had the problem in the month link when the user is at the year view and I fixed it by patching the file

on line 55 commenting out the

    //$calendar_links[] = $base + array('title' => date_t('Month', 'datetime'), 'href' => date_real_url($view, 'month'));

and adding

    $month_now = date("m");
    $year_now = date("Y");
    $url = date_real_url($view, NULL, $year_now . '-' . $month_now);
    $calendar_links[] = $base + array('title' => date_t('Month', 'datetime'), 'href' => $url);
squiggy’s picture

I was mistaken in my last comment. But #18 did help fix this issue for me.

fullerja’s picture

I am having this issue as well. I tried to apply the patch in #16. But I get "HUNK #1 failed at 27."
I would really appreciate any advice.

dkinzer’s picture

The granularity bit did not work for me. But I applied patch at #16 #396152-16: Navigation links (Month, week, and day) sometimes incorrect and it works perfectly for me.

dkinzer’s picture

Status:Needs work» Needs review
dkinzer’s picture

Status:Needs review» Reviewed & tested by the community
PROMES’s picture

Version:6.x-2.2» 6.x-2.4
Status:Reviewed & tested by the community» Needs work

I discovered some problems today with start/end of the year. My weeks start on monday.
The results are very confusing for visitors and myself as well.

When I go to week view 2012-W52 (2012-12-24 to 2012-12-30):
Next week = 2012-W1 => should be 2013-W1
In day view 2012-12-31 the weeknumber is 2012-W01

When I go to week view 2013-W1 (2012-12-31 to 2013-01-06):
The year tab is: 2013: correct if based on the weeknumber, wrong when based on the first day of the week
The month tab is: 2013-12 => should be 2012-12 (based on the first day of the week, otherwise 2013-01)
The day tab is: 2013-12-31 => should be, of course, 2012-12-31.

When I apply patch #16 + addendum #17:
Same results.

On what day of the week / date the year, week and day numbers are calculated?
On end of the year it seems to be: first day of the week (like week view 2013-W1: based on monday 2012-12-31)
On start of a month: first day of the month (like month view 2013-01: based on tuesday 2013-01-01; monday 2012-12-31 = grey: not in view)