Skip to content

fix: round the current date to whole seconds so occurrences on the end date are returned - #436

Merged
harrisiirak merged 1 commit into
masterfrom
fix/end-date-millisecond-boundary
Aug 2, 2026
Merged

fix: round the current date to whole seconds so occurrences on the end date are returned#436
harrisiirak merged 1 commit into
masterfrom
fix/end-date-millisecond-boundary

Conversation

@harrisiirak

Copy link
Copy Markdown
Owner

Description

An occurrence falling exactly on endDate is missed when currentDate carries milliseconds (any new Date() in practice): the millisecond remainder is kept through iteration, so the candidate compares as endDate + ms and throws Out of the time span range. The current date is now rounded to whole seconds once per search - up for next(), down for prev() - restoring 4.9.0 behaviour.

Fixes #385

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • All tests pass (npm test)
  • Code coverage is maintained or improved

Changes Made

  • CronExpression.#findSchedule - rounds the current date to whole seconds before the search loop; the per-step millisecond handling this made unreachable is removed.
  • Three tests: the end-date regression, the sub-second start-date throw, interleaved next/prev anchoring.

@harrisiirak harrisiirak self-assigned this Aug 2, 2026
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Quality gates · commit 970db12

Coverage

Statements Branches Functions Lines
100% 100% 100% 100%

Benchmark — vs cron-parser@5.7.0 (npm latest)

10000 iterations × 5 samples per pattern. A positive change is faster than the baseline.

Pattern Baseline This PR Change
0 0 0 15 * 5#3 722.03ms 711.16ms +1.51%
0 0 0 8 * 5#3 686.62ms 678.37ms +1.20%
0 0 6-20/2,L 2 * 521.09ms 516.66ms +0.85%
0 0 0 * * 5#3 1217.65ms 1208.81ms +0.73%
0 0 0 * * 1L,5L 686.40ms 682.00ms +0.64%
10-30/2 2 12 8 0 156.08ms 155.22ms +0.55%
0 12 */5 6 * 466.46ms 464.02ms +0.52%
H H H(9-20)/3 1-11 * 430.66ms 428.67ms +0.46%
0 0 0 * * 4,6L 344.49ms 343.07ms +0.41%
0 H * * * 173.35ms 172.64ms +0.41%
0 15 */5 5 * 450.31ms 449.49ms +0.18%
10 2 12 8 7 735.04ms 733.91ms +0.15%
0 H/3 * * * 165.63ms 165.43ms +0.12%
* * * * * * 52.95ms 52.92ms +0.06%
0 * * 1,4-10,L * * 93.06ms 94.30ms -1.34%

Informational only. Runner timings are noisy and this check never fails.

@harrisiirak
harrisiirak merged commit 8410d37 into master Aug 2, 2026
8 checks passed
@harrisiirak
harrisiirak deleted the fix/end-date-millisecond-boundary branch August 2, 2026 21:48
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.

Regression in 5.3.0 — endDate is no longer inclusive, leading to missing occurrences

1 participant