Skip to content

Fix showSixWeeks page() using aligned span instead of /6 heuristic#2780

Open
Norcy wants to merge 1 commit into
wix:masterfrom
Norcy:fix/show-six-weeks-page-span
Open

Fix showSixWeeks page() using aligned span instead of /6 heuristic#2780
Norcy wants to merge 1 commit into
wix:masterfrom
Norcy:fix/show-six-weeks-page-span

Conversation

@Norcy

@Norcy Norcy commented Apr 18, 2026

Copy link
Copy Markdown

Problem

When showSixWeeks is true, page() used (daysBefore + monthLength) / 6 >= 6 to decide whether to extend to by 7 days. This does not match the real week-aligned cell count and caused:

  • An extra 7th row in some months (e.g. March 2026 with firstDay=1).
  • Missing trailing next-month cells when the heuristic skipped the extension (e.g. May 2026 stayed at 5 weeks).

Solution

After aligning from and to to week boundaries, extend by one week only when from.diffDays(to) + 1 < 42. Remove the /6 heuristic and the unused daysBefore variable.

Testing

yarn test src/dateutils.spec.js

Made with Cursor

Replace (daysBefore + monthLength) / 6 with week-aligned span check:
extend by one week only when from.diffDays(to) + 1 < 42.

Fixes extra 7th row (e.g. March 2026 with firstDay=1) and missing
trailing next-month cells (e.g. May 2026 staying at 5 weeks).

Made-with: Cursor
@CreatlV

CreatlV commented Jul 17, 2026

Copy link
Copy Markdown

Thanks for tackling this β€” using the aligned page span is much clearer than the current / 6 heuristic.

There is one remaining edge case: February 2026 with firstDay={0}. After alignment, from through to spans 28 days, so adding a single week produces 35 days (five rows), not 42.

Could the extension add the exact missing number of days instead?

const daysOnPage = from.diffDays(to) + 1;

if (showSixWeeks && daysOnPage < 42) {
  to.addDays(42 - daysOnPage);
}

That gives 28 β†’ 42, 35 β†’ 42, and leaves 42 unchanged. It would be good to add regression cases for February 2026 with a Sunday start, May 2026 with a Monday start, and a month that naturally spans six rows. I also checked this calculation across 1900–2100 with firstDay values 0–6; every showSixWeeks page resolves to 42 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants