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

Open
#55 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
backend

Research direction

Start by reading the interval range implementation and its tests in the d3-time repository to see how the stop boundary is currently handled. Explore how an option that includes the stop boundary could fit the existing range API, including its default behavior. Done means ranges include the stop interval when requested while preserving the current exclusive default, with tests covering both cases.

Written by the indexing model from the issue text.

Description

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.

Dominant language
JavaScript
Stars
238
Forks
55
Avg merge
6h 15m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from d3/d3-time

All issues in d3/d3-time

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.