This small library allows you tocheck if a date is within a range. Support includes repeating ranges using the ISO 8601 standards of Durations and Repeating Intervals.
This can be supplied a range with describes a duration at a repeating interval (for example between 9:15 and 4 every other Thursday) and can tell you if a date falls within one of those ranges.
var IntervalRecurrence = require('iso8601-interval-recurrence');
var range = {
interval: '2015-07-22T00:00:00.000Z/P1D',
recurrence: 'R/P1W'
};
var every_wednesday = new IntervalRecurrence(range);
var wednesday = '2015-07-29T13:00:00.000Z';
var tuesday = '2015-07-23T11:12:13.000Z';
every_wednesday.containsDate(wednesday); // true
every_wednesday.containsDate(tuesday); // false
Although I will write some more documentation later, for now you can see the unit testing to determine how to use it.
The guys over at cylc seemed to have the same problem but came up with a complicated and extremely confusing solution.
I worked on this with Joshua Finch, who has published an equivalent library for iOS.