Skip to content

getOpenIntervals skips valid dates when start date is inside range for week x-y/N <weekday> #524

@Calderis

Description

@Calderis

Version: 3.9.0 (reproduced in CodeSandbox)
Minimal repro (CodeSandbox): https://codesandbox.io/p/sandbox/javascript-forked-dgcsf9
Can also be reproduced on : https://openingh.ypid.de/evaluation_tool/?lng=fr
Environment:

  • Browser (CodeSandbox) and Node
  • Time zone: Europe/Paris (but issue seems logic-related, not TZ-specific)

Rule under test:

2025 week 2-52/6 Fr 00:00-24:00

Meaning: in 2025, open all day on Fridays of ISO weeks 2, 8, 14, 20, 26, 32, 38, 44, 50.

Actual behavior:

  • When from = 2025-08-01T00:00:00, the output is [] (no intervals returned).
  • When from = 2025-07-01T00:00:00, the output contains 4 intervals:
    • 2025-08-08
    • 2025-09-19
    • 2025-10-31
    • 2025-12-12

Expected behavior:
For the same rule and [from=2025-08-01, to=2026-04-01], getOpenIntervals should return the same 4 dates (Aug 8, Sep 19, Oct 31, Dec 12), regardless of whether from is July 1 or Aug 1. In other words, moving from forward inside the validity period should not make previously valid future intervals disappear.

Why this seems wrong:

  • The rule uses ISO week stepping: week 2-52/6 Fr ⇒ weeks 2, 8, 14, 20, 26, 32, 38, 44, 50.
  • With from = 2025-08-01 (week 31), the next valid Friday is week 32 → 2025-08-08.
  • Yet getOpenIntervals returns no intervals, as if the step /6 anchoring or internal iterator state skips ahead incorrectly when the start date is already inside the range.

Hypothesis:

There may be an off-by-one or anchoring bug in the computation of the next matching /N week when from is after the first eligible anchor within the given year and week range. The iterator might fail to “snap forward” to the next valid step boundary (week 32 in this case) and instead returns nothing.

Workarounds tried:

  • Starting the search earlier (e.g., from one month earlier) makes intervals appear, but that’s not a viable general workaround.
  • Also tried on https://openingh.ypid.de/evaluation_tool/?lng=fr with 2025-sept-29 as starting date that give only the 12 december and the 2025-sept-28 has starting date that return 12 december AND 31 october

Thanks fo the library and for your work

Metadata

Metadata

Labels

type: bugA confirmed report of unexpected behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions