houdini/client/js/components/date-range.js

11 lines
316 B
JavaScript
Raw Normal View History

const moment = require('moment')
require('moment-range')
// returns an array of moments
// timeSpan is one of 'day, 'week', 'month', 'year' (see moment.js docs)
module.exports = (startDate, endDate, timeSpan) => {
var dates = [moment(startDate), moment(endDate)]
return moment.range(dates).toArray(timeSpan)
}