Manipulation with date periods: intersection, splitting etc.
Days interval has always its first and last day included.
Creates new interval data structure:
{firstDay: 'YYYY-MM-DD', lastDay: 'YYYY-MM-DD'}
Creates new interval as intersection of given two. Returns undefined
if intervals have no intersection.
Creates array of intervals as parts of baseInterval
divided by splitterInterval
.
baseInterval: ______bbbbbbbb________
splitterInterval: ________ssss__________
result: ______11______________
________2222__________
____________33________
Creates array of intervals. Resulting intervals include all days of source intervals, but have no intersections.
source: ______1111111______
_________222_______
_________33333_____
_________________44
result: ______111__________
_________222_______
____________3______
_____________4_____
_________________55
Creates array of adjacent intervals defined by set of its first days.
source: ___d____d______d__
result: ____11111__________
_________22222222__
Last day in set will be the last day of last interval. First and last days can be ±Infinity
Start npm run tdd
and enjoy!