When navigating the 2017 calendar by weeks, (first day of week Sunday, not using ISO weeks) I noticed that when using going from 2017-W02 (2017-01-08), the previous week is 2016-W01, not 2017-W01.

The issue is that the year blindly uses the ISO year. So what could be week 52 or 53 of the previous year in ISO, is actually week 1 of the next year.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

rsmylski created an issue. See original summary.

Anonymous’s picture

Status: Active » Needs review
FileSize
5.14 KB

I've created a patch to have a function calculate the year, using some of the logic used to calculate the weeks, and updated accordingly.

Anonymous’s picture

FileSize
5.14 KB

Fixed using incorrect int_val() instead of intval()

jastraat’s picture

This fixed the issue for me with 7.x-2.10

Nina Lisitsinskaya’s picture

Hello. I have very similar problems with the weeks calendar. This patch seems to solve most of the problems, but not all of them.
For example, on the week 52 of 2018 I see the next link leading to the week 53 of 2019.
I'm using Drupal 7.59, version 7.x-3.5 of the Calendar module, and the latest 7.x-2.x-dev version of the Date module. This is my time settings:
Time settings

Nina Lisitsinskaya’s picture

FileSize
5.13 KB
481 bytes

Probably there was a mistake in the patch. With this correction, everything seems to working ok.

pasi.valkeila’s picture

#6 fixed the issue for me as well for year 2018->2019 and 2020->2021. Thank you Nina! Still problem exists for me at 2020-W53. Next week -button skips one week straight to 2021-W02. Same settings for me that are in #5 except timezone: Europe/Helsinki and country: Finland

jastraat’s picture

I'm not sure this patch is necessary in 7.x-2.11-beta1.

Chris Matthews’s picture

Re: #8

I'm not sure this patch is necessary in 7.x-2.11-beta1.

@jastraat, have you tested 7.x-2.11-beta2 to see if this issue exists?

jastraat’s picture

Unfortunately I just tested with 7.x-2.11-beta2 using the 2017-W02 scenario, and this is still an issue.

jastraat’s picture

The patch from #6 still applies (with fuzz) and fixes the issue.

Jorrit’s picture

Works for me. There is room for small improvements by calculating the argument to date_week() and date_week_year() just once, for instance calculate date_format($now, 'Y-m-d') just once in date_views_argument_handler_simple::get_default_argument.

Jorrit’s picture

Here is a patch that performs the above optimization.

DamienMcKenna’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This is great work, but I think we should include some tests to make sure it works as intended.

Jorrit’s picture

Status: Needs work » Needs review
FileSize
8.25 KB

I've added some tests.

Jorrit’s picture

Are these tests sufficient, DamienMcKenna ?

silverham’s picture

I getting same issue now when using the calendar module (version 7.x-3.6) on D7.

"week=2021-W03" => click previous week button turns incorrectly into "week=2020-W02" (skipping a year).

I've rerolled the patch for date module 7.x-2.x-dev / 7.x-2.11-rc1.

DamienMcKenna’s picture

I wonder - should the DateObject class be extended to include this new week_year attribute?

DamienMcKenna’s picture

DamienMcKenna’s picture

Rerolled.