Problem
I have by week pager, so when i click to the 2015-W53 and then next it jumps to 2016-W02, so the first week is gone. and later all that year it counting weeks from 2nd. Nothing bad, just simple drupal numbers, but... i have this issue on calendar and since that is happening i've lost some events

Selecting 23.02.2016 on calendar (it is in the8th week of 2016) shows 2016-W08 in pager link and Week of Monday, February 15, 2016. So as calendar show 15.02.2016 belongs to 7th week, not to 8th what i was selected.

Comments

nikita.izotov’s picture

Assigned: nikita.izotov » Unassigned
predy’s picture

StatusFileSize
new529 bytes

I've recently come across this issue. The problem is that in the date_api (when ISO standard is respected) the line where the date object is modified with the value of the next Monday is given in a wrong format.

+ 1 Monday is invalid for strtotime().

My patch solves this problem.

predy’s picture

Component: Views Argument » Date API
Status: Active » Needs review
anpolimus’s picture

Assigned: Unassigned » anpolimus
Issue tags: +Needs tests

Needs test first.

anpolimus’s picture

Status: Needs review » Needs work
yaelsho’s picture

Any idea how to solve this issue for site which can't "Use ISO-8601 week numbers"?

Peter Arius’s picture

date 7.x-2.9+5-dev (2015-Dez-10)
calendar 7.x-3.5

confirming that patch #2 (#2416421-2: Wrong week numbering for 2016) solves the problem for me

rv0’s picture

anpolimus’s picture

Needs reroll

luison’s picture

Comment #2, works for me.

anpolimus’s picture

akolahi’s picture

Patch #2 also solves the problem for me :)

loziju’s picture

Version: 7.x-2.8 » 7.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new529 bytes

Tested #2 is working for me, too.

Rerolled for 7.x-2.x-dev.

moonray’s picture

Status: Needs review » Needs work

This isn't a complete fix. `date_week_range()` function needs fixing as well.

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new1.28 KB

Here's a patch that includes updates to date_week_range() function, when not using iso8601.

moonray’s picture

Here's a patch that includes updates to date_week_range() function, when not using iso8601.

moonray’s picture

StatusFileSize
new1.43 KB

Fixed the end date that the date_week_range function provides to make sure it includes dates on the last day of the week.

rv0’s picture

Restating (see #8) that https://www.drupal.org/node/1874422 is fixing the exact same issue and has a working patch in #23
not sure which is better, but only one issue should be active.

loziju’s picture

Afaik https://www.drupal.org/node/1874422 only solves the next link. It didn't solve the problem described by @anpolimus.

Surely it didn't solve the issue I have, which is the same as the one faced by @anpolimus.

loziju’s picture

Sorry I may be too quick to comment above. I got mixed up with another next link issue thread. Let me retry on my end.

admiralfdg’s picture

#17 fixes the week numbering but breaks the pager back links (they point to the current week) and misidentifies the current week (a week ahead, so the week of the 17th is showing the 24th) on my install.

drasgardian’s picture

StatusFileSize
new5.19 KB

Attached patch corrects the pager links.

The difficulty was getting date_week() to convert an ISO week to a calendar week, taking into account the complexity of ISO weeks, which start on Mondays rather than Sundays, yet the first Monday of a year is not necessarily the first week of the year. The week with the first Thursday in it is the first week of the year.. did my head in for a while.

Status: Needs review » Needs work

The last submitted patch, 22: date-wrong_week_numbering-2416421-22.patch, failed testing.

moonray’s picture

The patch doesn't handle date_week() and date_week_range () properly. Needs work.

hass’s picture

There is a patch for months issue.

hass’s picture

+++ b/date_api/date_api.module
@@ -2046,17 +2046,19 @@ function date_week_range($week, $year) {
+  date_modify($max_date, '+7 days - 1 second');

I guess 7 days is clearer...

erik frèrejean’s picture

@hass, the month issue appears to be something different. That one is caused because date_modify('...', '+1 month'); actually adds the number of days in the current month. So januari has 31 days, causing "Januari 31st + 31 -> February 31st -> March 2nd". This seems to be a slightly different issue which I'm not familiar with.

However there is a lot of inconsistency across PHP versions when modifying the date with a week: https://3v4l.org/94PBa

SeanA’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)
Related issues: +#1874422: Pager may cause incorrect "prev" or "next" link

The patch at #23 on #1874422: Pager may cause incorrect "prev" or "next" link works for me... but part of the fix has already been committed to 2.x-dev #2375235: Calendar block Next/Prev navigation broken, so the patch there needs to be re-rolled (see maintainer's request on that thread). The patch here and the patch there are both dealing with the same bits of code, so let's keep our efforts together on one issue.