Skip to content

Instantly share code, notes, and snippets.

@homleen
Last active December 20, 2015 19:19
Show Gist options
  • Save homleen/6182232 to your computer and use it in GitHub Desktop.
Save homleen/6182232 to your computer and use it in GitHub Desktop.
生成2013年所有的日期,并随即生成一个对应的值
'use strict';
var start = new Date(2013, 0, 1);
var end = new Date(2014, 0, 1);
var data = [];
while (start < end) {
data.push( [start.getTime() / 1000, Math.floor( Math.random() * 6) ] );
start = new Date(start.setDate(
start.getDate() + 1
));
}
'use strict';
var start = new Date(2013, 0, 1);
var end = new Date(2014, 0, 1);
var dates = {};
while (start < end) {
var prop = start.getTime() / 1000;
dates[prop] = Math.floor( Math.random() * 6 );
start = new Date(start.setDate(
start.getDate() + 1
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment