daterange-list
v0.0.1
Published
A utility to create a list of date ranges
Downloads
1
Readme
daterange-list
Create an array of daterange objects.
Usage
var daterange = require('daterange-list.js');
var dateOptions = {};
function getAvailableDates(weeks) {
var titles = daterange.createDateTitles(weeks);
for (var i = 0, j = 1; i < weeks; i++, j++) {
dateOptions[titles[i]] = [
daterange.getMondayOfWeek(j),
daterange.getFridayOfWeek(j)
];
}
}
getAvailableDates(10);
getAvailableDate()
will return an object with the following format:
{
'09/05/2016 to 09/09/2016':
[ { [Number: 1473048000000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-09-05T04:00:00.000Z,
_isValid: true },
{ [Number: 1473393600000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-09-09T04:00:00.000Z,
_isValid: true } ],
'09/12/2016 to 09/16/2016':
[ { [Number: 1473652800000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-09-12T04:00:00.000Z,
_isValid: true },
{ [Number: 1473998400000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-09-16T04:00:00.000Z,
_isValid: true } ],
'09/19/2016 to 09/23/2016':
[ { [Number: 1474257600000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-09-19T04:00:00.000Z,
_isValid: true },
{ [Number: 1474603200000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-09-23T04:00:00.000Z,
_isValid: true } ],
'09/26/2016 to 09/30/2016':
[ { [Number: 1474862400000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-09-26T04:00:00.000Z,
_isValid: true },
{ [Number: 1475208000000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-09-30T04:00:00.000Z,
_isValid: true } ],
'10/03/2016 to 10/07/2016':
[ { [Number: 1475467200000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-03T04:00:00.000Z,
_isValid: true },
{ [Number: 1475812800000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-07T04:00:00.000Z,
_isValid: true } ],
'10/10/2016 to 10/14/2016':
[ { [Number: 1476072000000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-10T04:00:00.000Z,
_isValid: true },
{ [Number: 1476417600000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-14T04:00:00.000Z,
_isValid: true } ],
'10/17/2016 to 10/21/2016':
[ { [Number: 1476676800000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-17T04:00:00.000Z,
_isValid: true },
{ [Number: 1477022400000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-21T04:00:00.000Z,
_isValid: true } ],
'10/24/2016 to 10/28/2016':
[ { [Number: 1477281600000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-24T04:00:00.000Z,
_isValid: true },
{ [Number: 1477627200000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-28T04:00:00.000Z,
_isValid: true } ],
'10/31/2016 to 11/04/2016':
[ { [Number: 1477886400000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-10-31T04:00:00.000Z,
_isValid: true },
{ [Number: 1478232000000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-11-04T04:00:00.000Z,
_isValid: true } ],
'11/07/2016 to 11/11/2016':
[ { [Number: 1478494800000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-11-07T05:00:00.000Z,
_isValid: true },
{ [Number: 1478840400000]
_isAMomentObject: true,
_isUTC: false,
_pf: [Object],
_locale: [Object],
_d: 2016-11-11T05:00:00.000Z,
_isValid: true }
]
}