5.1.0 • Published 3 months ago

dates-between v5.1.0

Weekly downloads
143
License
MIT
Repository
github
Last release
3 months ago

Dates Between

Get all of the dates between two given dates, with generators.

const startDate = new Date('2016-01-01');
const endDate = new Date('2017-01-01');

for (const date of datesBetween(startDate, endDate)) {
    console.log(date);
}

Table of Contents

Requirements

This library requires the following to run:

Usage

Install with npm:

npm install dates-between

Load the library into your code with a require call:

const datesBetween = require('dates-between');

The datesBetween function accepts two arguments, a start date and an end date. Both of these must be Date objects:

datesBetween(new Date('2016-01-01'), new Date('2016-02-01'));

This returns an iterable which can be iterated over in a for..of construct. The yielded dates include both the start and end date that were passed in.

for (const date of datesBetween(startDate, endDate)) {
    console.log(date);
}

Because datesBetween returns an iterable, you can also create a Set or Array from it:

const dates = new Set(datesBetween(startDate, endDate));
const dates = Array.from(datesBetween(startDate, endDate));

Usage examples can be found in the example directory of this repository.

Contributing

The contributing guide is available here. All contributors must follow this library's code of conduct.

License

Licensed under the MIT license. Copyright © 2016, Rowan Manning

5.1.0

3 months ago

5.0.0

8 months ago

4.0.2

10 months ago

4.0.1

1 year ago

4.0.0

1 year ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago