Created
July 7, 2016 17:04
-
-
Save RuffSeason/23b86b6a0cfa33f140a52e39130bf584 to your computer and use it in GitHub Desktop.
Date Range Timestamps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var moment = require('moment'); | |
// create truncated date ranges to fill with zeros | |
var enumerateDaysBetweenDates = function(startDate, endDate, granularity) { | |
var dates = []; | |
var currDate = startDate.clone().startOf(granularity); | |
var lastDate = endDate.clone().endOf(granularity); | |
while(currDate.add(granularity, 1).diff(lastDate) < 0) { | |
console.log(currDate.toDate()); | |
dates.push(currDate.clone().toDate()); | |
} | |
return dates; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment