Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtered intervals' offset() function doesn't work correctly when step is negative #24

Closed
douglyuckling opened this issue Jun 14, 2017 · 1 comment

Comments

@douglyuckling
Copy link

The offset() function of filtered intervals doesn't seem to work as intended when the given step is negative:

const interval = d3.utcMinute.every(15);
const date = new Date("Fri, 14 Jul 2017 12:07:23 GMT");
console.log(interval.offset(date, 1).toUTCString()); // Fri, 14 Jul 2017 12:15:23 GMT (correct)
console.log(interval.offset(date, -1).toUTCString()); // Fri, 14 Jul 2017 12:07:23 GMT (incorrect)

(Here's a runnable version on CodePen.)

Looking at the D3 code, the problem is pretty clear:

if (date >= date) while (--step >= 0) while (offseti(date, 1), !test(date)) {}
@mbostock
Copy link
Member

Fixed in 1.0.7. Thanks for the report!

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

No branches or pull requests

2 participants