node.jsでタイムスタンプの羅列を日毎に集計する

var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  var lines = input.split(/[\r\n]+/);
  var data = new Object();
  for (var i in lines) {
      var date = new Date();
      var time = parseInt(lines[i]);
      if(time) {
        date.setTime(time * 1000);
      }
      var indexDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
          if(!data.hasOwnProperty(indexDate)){
          data[indexDate] = new Array();
      }
      data[indexDate].push(time);
  }

  for (var j in data) {
      console.log(j + "\t" + data[j].length);
  }
});