Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#20 | date-n2868485-20.patch | 8.17 KB | DamienMcKenna |
| |||
#17 | 2868485-date-week-year-17.patch | 8.32 KB | silverham |
| |||
#15 | 2868485-date-week-year-15.patch | 8.25 KB | Jorrit |
| |||
#3 | wrong_year_non_iso-2868485-3.patch | 5.14 KB | Anonymous (not verified) |
|
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous at Cheeky Monkey Media commentedrsmylski created an issue. See original summary.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous at Cheeky Monkey Media commentedI've created a patch to have a function calculate the year, using some of the logic used to calculate the weeks, and updated accordingly.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous at Cheeky Monkey Media commentedFixed using incorrect int_val() instead of intval()
Comment #4
jastraat CreditAttribution: jastraat at Technivant commentedThis fixed the issue for me with 7.x-2.10
Comment #5
Nina Lisitsinskaya CreditAttribution: Nina Lisitsinskaya commentedHello. 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:
Comment #6
Nina Lisitsinskaya CreditAttribution: Nina Lisitsinskaya commentedProbably there was a mistake in the patch. With this correction, everything seems to working ok.
Comment #7
pasi.valkeila CreditAttribution: pasi.valkeila commented#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
Comment #8
jastraat CreditAttribution: jastraat at Technivant commentedI'm not sure this patch is necessary in 7.x-2.11-beta1.
Comment #9
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedRe: #8
@jastraat, have you tested 7.x-2.11-beta2 to see if this issue exists?
Comment #10
jastraat CreditAttribution: jastraat at Technivant commentedUnfortunately I just tested with 7.x-2.11-beta2 using the 2017-W02 scenario, and this is still an issue.
Comment #11
jastraat CreditAttribution: jastraat at Technivant commentedThe patch from #6 still applies (with fuzz) and fixes the issue.
Comment #12
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedWorks for me. There is room for small improvements by calculating the argument to
date_week()
anddate_week_year()
just once, for instance calculatedate_format($now, 'Y-m-d')
just once indate_views_argument_handler_simple::get_default_argument
.Comment #13
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedHere is a patch that performs the above optimization.
Comment #14
DamienMcKennaThis is great work, but I think we should include some tests to make sure it works as intended.
Comment #15
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedI've added some tests.
Comment #16
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedAre these tests sufficient, DamienMcKenna ?
Comment #17
silverham CreditAttribution: silverham at EY Digital commentedI 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.
Comment #18
DamienMcKennaI wonder - should the DateObject class be extended to include this new week_year attribute?
Comment #19
DamienMcKennaComment #20
DamienMcKennaRerolled.