Check if a number is in your min-max bounds.
- Builds into the Number prototype
- 100% code coverage
npm install btwn
yarn add btwn
Checking a number
var btwn = ;var x = 12; // a normal Number type variableifxconsole;elseconsole;
Checking a date
var btwn = ;// Bounds are 09:00-09:59 (inclusive)var minDate = 2017 00 01 09 00 00 00;var maxDate = 2017 00 01 09 59 59 00;var min = minDate false false false true true false false; //See the usage of these booleans in the docs belowvar max = maxDate false false false true true true false; //See the usage of these booleans in the docs belowvar d = ; //Current date & timeifdconsole;elseconsole;
Use in browser
Download the latest
btwn.js from here, and follow the instructions above without the
BoundDate(date, year, month, day, hours, minutes, seconds, [ms])
- date - Input date.
- year - Should the year be included as a bound?
- month - Should the month be included as a bound?
- day - Should the day ("date" in the Date object) be included as a bound?
- hours - Should the hours be included as a bound?
- minutes - Should the minutes be included as a bound?
- seconds - Should the seconds be included as a bound?
- ms - Should the milliseconds be included as a bound? (Default: false)
Number.btwn(min, max, [inclusive])
- min - Minimum value.
- max - Maximum value.
- inclusive - Are min and max inclusive. (Default: true)
Date.btwn(min, max, [inclusive])
- min - Minimum DateBound.
- max - Maximum DateBound.
- inclusive - Are min and max inclusive (Default: true)
- Integrate into dates