# daterange
daterange is a simple node/browser library to work with date ranges.
Compare whether date ranges are equal, overlap, or contain each other.
Subtract and add date ranges.
daterange is simple and fast.
Install via
npm install daterange
bower install daterange
The bower install is just the main src file, bower.json and readme
Basic Examples
Node Example
var daterange = ;var range1 = daterange;
Browser Example
Examples cont.
Add 2 ranges:
var range1 = daterange;var range2 = daterange;var result = range1; result0start === range1start; // trueresult0end === range2end; // true
Sum 2 continuous ranges:
var range1 = daterange;var range2 = daterange;var result = daterange; result0start === range1start; // trueresult0end === range2end; // true
Sum 3 ranges with break inbetween:
var range1 = daterange;var range2 = daterange;var range3 = daterange;var result = daterange; resultlength; // 2result0start === range1start; // trueresult0end === range2end; // trueresult1start === range3start; // trueresult1end === range3end; // true
Inverse ( Identify gaps in summed ranges ):
var range1 = daterange;var range2 = daterange;var result = daterange; result0start === range1end; // trueresult0end === range2start; // true
// Illustration://// range1 end1 start2 end2// v v v v// #-------------# #------#//// #-----#// ^ ^// start GAP end
daterange Methods:
range = daterange;ranges = daterange;bool = daterange;bool = daterange;bool = daterange;ranges = daterange;
daterange Instance Methods, from daterange.create:
bool = range;bool = range;bool = range;ranges = range;ranges = range;
tests
Run tests
npm test
Run tests and code coverage report
npm run coverage
License
The MIT License (MIT)
Copyright (c) 2014 Jarrett Widman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.