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

interval.every can return intervals of inconsistent length #64

Open
mbostock opened this issue Jun 27, 2023 · 1 comment · May be fixed by #66
Open

interval.every can return intervals of inconsistent length #64

mbostock opened this issue Jun 27, 2023 · 1 comment · May be fixed by #66

Comments

@mbostock
Copy link
Member

mbostock commented Jun 27, 2023

It’s weird that d3.utcMonth.every(9) alternates between 3- and 9-month intervals since the field number resets when the year changes. It’d be more obvious if this irregular interval were called d3.utcYearMonth, like we do with d3.utcMonthDay. Same for local time.

Related #62 #63.

@mbostock
Copy link
Member Author

There’s a similar issue with d3.utcHour and d3.timeHour: if you use d3.utcHour.every(5), you get a combination of 5- and 4-hour intervals since it resets at midnight; and if you pass a period greater than 24 such as d3.utcHour.every(48), it’s equivalent to d3.utcHour.every(24).

Maybe we don’t need new intervals — maybe we need to change the behavior of interval.every? We could have two variants of interval.every: one that returns strictly every nth interval (relative to UNIX epoch or some other arbitrary zero), while the other is allowed to reset to align within some parent interval (the current behavior). Or we even change the behavior of interval.every to be the strict variant (and deprecating unixDay since it will now be the same as utcDay). Would that require a major version bump? 🤔

It’s a challenge for d3.timeHour, though, since it would mean that d3.timeHour.every(6) is not guaranteed to return 12AM, 6AM, 12PM, 6PM because of daylight saving time; it might return 1AM, 7AM, 1PM, 7PM or 11PM, 5AM, 11AM, 5PM. That is unavoidable if the requirement is that the returned intervals are always six hours apart. 🤔 I think that suggests we need both, but maybe we only need both for d3.timeHour and everything else can have the strict behavior?

@mbostock mbostock changed the title Separate d3.utcMonth and d3.utcYearMonth interval.every can return intervals of inconsistent length Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant