You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/04/27 16:38:27 UTC

[GitHub] willholley commented on issue #1295: View MapFunction incorrect date parsing

willholley commented on issue #1295: View MapFunction incorrect date parsing
URL: https://github.com/apache/couchdb/issues/1295#issuecomment-385025518
 
 
   @tudordumitriu I think the issue is that `setDate` is modifying the date object in place, changing the value after you've called `emit`. Instead, ensure you call `setDate` on a new Date object:
   
   ```
   function (doc) {
     if(doc.startDateTime){ 
       var currentDateTime = new Date(doc.startDateTime);          
       emit(currentDateTime, -1);
       var currentOccurenceNo = 0;
       
       while (currentOccurenceNo < 4) 
       {
         var newDateTime = new Date();
         newDateTime.setDate(currentDateTime.getDate() + 1);
         emit(newDateTime, currentOccurenceNo);
         currentDateTime = newDateTime;
         currentOccurenceNo ++;
       }
     }
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services