Get linearly spread array of dates between two dates, given count of desired dates - javascript, d3.js, moment.js -


let's have dates:

mon mar 31 2014 05:42:35 gmt+0200 (cest)

wed sep 02 2015 10:29:38 gmt+0200 (cest)

and totalnumberofdates = 37;

i'd array of 37 dates (first , last date should above), linearly spread between given dates.

i'd appreciate elegant solution in d3.js or moment.js

function getdaterange(startdate, enddate, steps) {     var stepsize = (enddate - startdate) / steps;     return d3.range(steps + 1).map(function(i){ return moment(startdate).add(stepsize * i, 'ms').todate() }); } 

where startdate , enddate date objects.

note function return array length steps+1. because point of view logical. if example want one step 12 14 oclock expect result [12oclock, 14oclock].


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -