d3-time icon indicating copy to clipboard operation
d3-time copied to clipboard

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

Open EE2dev opened this issue 3 years ago • 2 comments

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.

EE2dev avatar Jun 25 '22 14:06 EE2dev

See https://github.com/d3/d3-array/issues/90 and https://github.com/d3/d3-array/pull/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.

Fil avatar Jun 25 '22 15:06 Fil

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

EE2dev avatar Jun 25 '22 18:06 EE2dev