https://github.com/saintplay/are-intervals-overlapping
Check if two date intervals are overlapping
https://github.com/saintplay/are-intervals-overlapping
collision date-fns date-range dates intervals overlapping
Last synced: about 2 months ago
JSON representation
Check if two date intervals are overlapping
- Host: GitHub
- URL: https://github.com/saintplay/are-intervals-overlapping
- Owner: saintplay
- License: mit
- Created: 2017-12-11T15:21:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-13T14:08:14.000Z (over 7 years ago)
- Last Synced: 2025-02-09T11:33:52.303Z (2 months ago)
- Topics: collision, date-fns, date-range, dates, intervals, overlapping
- Language: JavaScript
- Size: 42 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# are-intervals-overlapping
> Check if two intervals are overlapping - Logic from date-fns
## Install ##
npm install --save are-intervals-overlapping
or
yarn add are-intervals-overlapping
## Usage ##
```js
var areIntervalsOverlappings = require('are-intervals-overlapping');
// or
import areIntervalsOverlappings from 'are-intervals-overlapping';// For overlapping time intervals:
areIntervalsOverlapping(
{start: new Date(2014, 0, 10), end: new Date(2014, 0, 20)},
{start: new Date(2014, 0, 17), end: new Date(2014, 0, 21)}
)
//=> true// For non-overlapping time intervals:
areIntervalsOverlapping(
{start: new Date(2014, 0, 10), end: new Date(2014, 0, 20)},
{start: new Date(2014, 0, 21), end: new Date(2014, 0, 22)}
)
//=> false// Using the inclusive option:
areIntervalsOverlapping(
{start: new Date(2014, 0, 10), end: new Date(2014, 0, 20)},
{start: new Date(2014, 0, 20), end: new Date(2014, 0, 24)}
)
//=> falseareIntervalsOverlapping(
{start: new Date(2014, 0, 10), end: new Date(2014, 0, 20)},
{start: new Date(2014, 0, 20), end: new Date(2014, 0, 24)},
{inclusive: true}
)
//=> true
```## License ##
MIT © [Diego Jara]([email protected])