time-slots
v1.0.1
Published
Zero dependency time slot library. Given a range start and end date, the timerange function will return available timeslots for an time increment value.
Downloads
5
Readme
Get time slots given a range of dates and an incremental value
Zero dependency time slot library. Given a range start and end date, the timerange function will return available timeslots for an time increment value.
/**
start: unix time (miliseconds)
end: unix time (miliseconds)
interval: unix time (miliseconds)
returns [unix time(miliseconds)]
*/
function timerange(start, end, increment) returns available time_slots array
From the unit test
let start = moment({hour:0}),
end = moment({hour: 24})
let slots = timeRange(start.valueOf(), end.valueOf(), 15*60)
//there are 96, 15 minute slots in a day
expect(slots.length).to.equal(96)
let end_included = slots.indexOf(end.valueOf) != -1
//the beginning of next day should not be included
expect(end_included).to.equal(false)
done()