Created
August 14, 2017 06:43
-
-
Save zymr-keshav/244e21703dcba59973146648e1ccf3c2 to your computer and use it in GitHub Desktop.
create default 12 hours tiem data with difference of 1 hour
This file contains hidden or 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
const getDatesRangeArray = function(startDate, endDate, unit, step) { | |
// console.log("getDatesRangeArray", arguments); | |
var interval = { | |
unit_: unit || 'hours', | |
step_: step || 1 | |
}, | |
dateArray = [], | |
currentDate = startDate; | |
// console.log("currentDate", currentDate); | |
while (currentDate <= endDate) { | |
// console.log('dateArray', dateArray); | |
dateArray.push(currentDate); | |
currentDate = moment(currentDate).add(interval.step_, interval.unit_).utc().valueOf(); // in milliseconds | |
// console.log("new currentDate in while", currentDate); | |
} | |
// console.log("final dateArray", dateArray); | |
return dateArray; | |
}; | |
const createDefaultTimeChart = function() { | |
//console.log("createDefaultLineChart"); | |
let endHour = moment().utc().valueOf(); // current timestamp | |
let startHour = moment(endHour).subtract(11, 'hours').utc().valueOf(); // current timestamp - 12 hours | |
getDatesRangeArray(startHour, endHour, 'hours', 1).then(function(timeSheet) { | |
console.log("timeSheet", timeSheet); | |
// vm.lineGraph.create(timeSheet); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment