#4336·date-fns

Fractional hour steps can cause an infinite loop

Author: StrohuttCreated Sep 27, 2026Updated Sep 27, 2026

On main 717ce0a807ea4c6b540d015b5c408723175b2838, fractional steps below one make eachHourOfInterval loop without advancing the date:

typescript
eachHourOfInterval(
  { start: new Date("2024-01-01T00:00:00Z"), end: new Date("2024-01-01T03:00:00Z") },
  { step: 0.5 },
);

Date.setHours(date.getHours() + step) discards the fraction. The next iteration therefore appends the same date again. -0.5 has the same problem after the sign is removed.

The Temporal implementation instead throws RangeError for fractional steps, including 1.5, which the Date implementation treats as a one-hour step.

Reproduced against the actual source with Node 26.10.0 and TZ=UTC. A separate child process times out for both sub-hour steps; the integer-step control exits normally. Four added cases fail in the existing Temporal suite, while its 21 existing cases pass.

Truncating the step before checking for zero and handling its sign would avoid the loop and give both implementations the same whole-hour behavior.