timeslotjs
v1.0.0
Published
Library implementing a timeslot functionality
Downloads
2
Readme
timeslotjs
This project is in active development. Breaking changes can and will occur as long as this notice is here
Intro
Specify a timeslot and determine if date is within said timeslot.
Say you need to allow a user to specify when they want notifications, you can specify a string such as "0800:1600:12345" which will be true between 0800 and 1600 Monday through Friday.
The project supports and uses:
Usage
Require the module
var timeslot = require('timeslotjs');
Objectify timeslot string
var timeslot = require('timeslotjs');
timeslot.objectify('0800:1530:04')
Stringify timeslot object
var timeslot = require('timeslotjs');
var timeslotObject = {
start: {hour: '08', minute: '00'},
end: {hour: '15', minute: '30'},
weekdays: [0,4]
}
timeslot.stringify(timeslotObject)
Match a timeslot to a timestamp
var timeslot = require('timeslotjs');
var timeslotObject = {
start: {hour: '08', minute: '00'},
end: {hour: '1'5, minute: '30'},
weekdays: [0,4]
}
timeslotObject.excluded = [
'2017-06-17T08:01:00+02:00',
'2017-06-16T08:01:00+02:00'
]
match(timeslotObject, '2017-06-18T08:01:00+02:00')//true if it matches, false if not