Date.prototype.between >= 0.1.4
Purpose
Determine if the current date is between (or equal to) start and end
Syntax
Date#between
(
Stringunit
Datestart
Dateend
);
Parameters
unit
- Result can also be true if it is in the same start-of-unit of the start or end date
start
end
Return values
Boolean
Examples
var start = new Date('2015-01-01'),
end = new Date('2015-03-10'),
a = new Date('2015-02-01'),
b = new Date('2014-02-01'),
c = new Date('2015-03-11');
a.between(start, end);>>> true
b.between(start, end);>>> false
c.between(start, end);>>> false
// Go to the start and end of the 2 given dates
c.between('month', start, end)>>> true // True because it is in (or between) the same month as start and end
Comments