title: mapReduce with date strange behavior
body: <p>&lt;&lt;
  Hello Guys,</p>
  
  <p>I work with Symfony2 (so Doctrine) and MongoDB. I'm trying to "group by" my results by date.
  I found a function to do that but its behavior is strange. </p>
  
  <p>The code:</p>
  
  <pre><code>    $qb = $this-&gt;dm-&gt;createQueryBuilder('Friends');
      $qb-&gt;map(new \MongoCode("function(){
                  var date = this.creationDate;
                  date.setHours(0);
                  date.setMinutes(0);
                  date.setSeconds(0);
                  day = date.getDate();
                  if(day &lt; 10){
                      day = '0'+day;
                  }
                  month = 1 + date.getMonth();
                  if(month &lt; 10){
                      month = '0'+month;
                  }
                  day = day+'/'+month+'/'+date.getFullYear();
                  emit(day, 1);
      }"));
      $qb-&gt;reduce(new \MongoCode("function(k, vals) {
                         var count = 0;
                         for(v in vals) {
                              count += 1;
                          };
  
                        return count;
                      }"
      ));
      $qb-&gt;sort("creationDate","desc");
  </code></pre>
  
  <p>The result:</p>
  
  <blockquote>
    <p>[timeMillis] => 96 [counts] => Array ( [input] => 2830 [emit] => 2830 [reduce] => 74 [output] => 79 ) [ok] => 1 ) )</p>
  </blockquote>
  
  <p>The input and th emit are good. But i don't understand why reduce and output are different.
  More when i'm trying to do a loop on all results, the total is different.</p>
  
  <p>Thanks you</p>