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.range() with option to include the stop interval boundary #55

Open
EE2dev opened this issue Jun 25, 2022 · 2 comments
Open

interval.range() with option to include the stop interval boundary #55

EE2dev opened this issue Jun 25, 2022 · 2 comments

Comments

@EE2dev
Copy link

EE2dev commented Jun 25, 2022

If you have a begin and an end date and want to loop through every day including the end date with d3.utcDay.range(), my understanding is I would call:
d3.utcDay.range(new Date("2022-03-08"), nextDay(new Date("2022-04-13")))

with

function nextDay(currentDay) {
  let nextDay = new Date(currentDay);
  nextDay.setDate(currentDay.getDate() + 1);
  return nextDay;
}

If interval range would include an option exclusive which defaults to true, but can be set to false, then one could get the desired result easier.

@Fil
Copy link
Member

Fil commented Jun 25, 2022

See d3/d3-array#90 and d3/d3-array#150 — although in the case of dates it's hard to call that linspace, since days/weeks/months don't always have the same duration.

@EE2dev
Copy link
Author

EE2dev commented Jun 25, 2022

What I am thinking of is using d3.utcDay.range() e.g. to get a list of days for school breaks or start and end travel dates. For both I want to include the last day

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