I'm running into a problem whereby the next month pager jumps two months. This was exposed after applying the patch for the bug Undefined variable: granularity in date_views_plugin_pager->query(). The pager functionality uses date_modify() to add one month onto next_date, which is set to the last day of the month. According to the php documentation for date_modify(), it takes the date, adds 1 to the month and then checks overflow of days (and presumably months).

So, 31st January 2015 becomes 31st February 2015 which becomes 3rd March 2015 and the pager jumps from January to March.

This might be a php version issue, I'm using php 5.3.29.

I've addressed this by adding 1 month to min_date instead of max_date when the granularity is set to month within date_views_plugin_pager.inc ~ line 285.

if ($argument->date_handler->granularity == 'month')
  $this->view->date_info->next_date = clone($argument->min_date);
else
  $this->view->date_info->next_date = clone($argument->max_date);

I figure this should always work assuming that min_date is always set to 1st of the month. However, I assume there must be a good reason for using max_date instead of min_date to get the next pager date so guess this will probably break something somewhere along the line. Is this an appropriate solution, is there a better solution or am I barking up the wrong tree?

I assume this issue will also be encountered when skip empty pages is true (which is not the case for me).

Looks like this has been fixed in the latest dev version :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

danwonac’s picture

Title: Next month pager jumping » Next month pager skipping months
Issue summary: View changes
danwonac’s picture

danwonac’s picture

danwonac’s picture

Issue summary: View changes
danwonac’s picture

Status: Active » Closed (works as designed)
my-family’s picture

Status: Closed (works as designed) » Active

I hope the reopening this issue is the right step because I am experiencing exactly the same behavior. However, in my case (7.x-2.9-beta2+9-dev) the problem does not seem to be fixed.

When I want to navigate (Next button) from a month with 31 days to a month with less than 31 days, the pagers skips the "short" month and navigates directly to the next 31-day-month.

Thank you in advance for help.

pwiniacki’s picture

@my-family same here.
EDIT: PREVIOUS button is working ok, but NEXT button skip a month with <31 days.

Lostboy22’s picture

Lostboy22’s picture

Component: Code » Views Filter
Related issues: +#2375235: Calendar block Next/Prev navigation broken

see fix for -dev version

taging to -dev

jeisel’s picture

I'm getting this problem, too - and I just updated yesterday.

cafuego’s picture

Status: Active » Closed (duplicate)

Closing as a dupe of #2375235: Calendar block Next/Prev navigation broken (which was filed a little bit earlier).

dstorozhuk’s picture

PREVIOUS button is working ok, but NEXT button skip a month with <31 days.

Same problem here.

Kathode’s picture

More testing results: on Android cell using Firefox the Next month button is skipping 1 month going from January to February, then to March. It displays April instead of March. On iPhone using Safari it is skipping forward 1 month from the start of using the Next button. I can't duplicate the skipping problem on desktop browsers.

Michelle’s picture

@dstorozhuk and @Kathode - This has been marked as a duplicate. You'll want to put your comments on #2375235: Calendar block Next/Prev navigation broken if they are still needed (that one is RTBC).

ianfunghk’s picture

I ran into the same issue now

EgbertB’s picture

Update to date 7.2-2.x-dev

https://www.drupal.org/project/date

icf-vpathak’s picture

Updating the Date module resolved the issue.