jquery-date-range-picker icon indicating copy to clipboard operation
jquery-date-range-picker copied to clipboard

BUG: Wrong week number displayed, only after having selected a date range

Open JPCrounse opened this issue 6 years ago • 5 comments

Here is a jsfiddle demonstrating this issue: https://jsfiddle.net/vhfrqtk6/1/

The issue can be replicated when selecting a date range starting in March 2019 and ending in April of 2019. When the picker is subsequently re-opened, the first week of April (week 14) displays as week 13.

This only seems to happen after a date range has been selected. Prior to selection the correct week number is displayed.

Here is a screen shot displaying the issue: https://imgur.com/a/Ngxb6nN

Best regards, JP

JPCrounse avatar Feb 20 '19 10:02 JPCrounse

If you're using moment, then getWeekNumber: (day) => moment(day).isoWeek() seems to do the trick.

hbulens avatar Jun 25 '20 11:06 hbulens

Same goes for the first three days of 2020.

image_2021_01_26T16_38_05_520Z

These days officially belong to week "2020-53" according to ISO week dates

Screenshot 2021-01-26 at 17 46 56

So https://github.com/longbill/jquery-date-range-picker/issues/475#issuecomment-649475836 might be a viable approach...

holtkamp avatar Jan 26 '21 16:01 holtkamp

If you're using moment, then getWeekNumber: (day) => moment(day).isoWeek() seems to do the trick.

This works but the code seems to use the first day of the week to determine the week number, so in case you're using Sunday as the start of the week you'll have to use this instead: getWeekNumber: (day) => moment(day).add(1, 'd').isoWeek()

JPCrounse avatar Feb 24 '21 08:02 JPCrounse

possibly related: #376

@monovertex maybe we should use the "ISO week" approach as suggested by https://github.com/longbill/jquery-date-range-picker/issues/475#issuecomment-649475836 as default option to align with overviews like http://www.whatweekisit.org

And then maybe do a check for which start of the week was used (Sunday or Monday) as suggested by https://github.com/longbill/jquery-date-range-picker/issues/475#issuecomment-784916207

holtkamp avatar Jul 07 '21 09:07 holtkamp

您好,邮件已收到!我会尽快处理的。

dlk1932 avatar Mar 04 '24 07:03 dlk1932