title: calculate date difference from JSON date strings
body: <p>I have dates stored in <code>timesheet.json</code> in this format:</p>
  
  <pre><code>[{"id":1,"note":"some note about task 1","start":"2015-08-28 02:41:02
      +0200","end":"2015-08-28 02:58:58 +0200","sheet":"job"},{"id":2,"note":"some
      note about task 2","start":"2015-09-03 03:15:04 +0200","end":"2015-09-03
      03:57:34 +0200","sheet":"job"},{"id":3,"note":"some note about task
      3","start":"2015-09-03 23:09:50 +0200","end":"2015-09-03 23:58:00
      +0200","sheet":"job"},{"id":5,"note":"this is a test task","start":"2015-09-08
      19:46:19 +0200","end":"2015-09-08 20:11:22 +0200","sheet":"job"}]
  </code></pre>
  
  <p>As I natively don't have a difference exported in json I am trying to
  calculate it myself, and append it to originally parsed json, before sending it to
  <code>handlebars.js</code> for template rendering.</p>
  
  <p>However I cannot convert the above string representations into <code>Date()</code>
  objects, to be able to do calculations on time difference.</p>
  
  <p>This construction works in <code>node</code> cli, and I can do <code>startTime.getTime()</code> but
  it doesn't work in javascript:</p>
  
  <pre><code>    var startTime = new Date('2015-08-28 02:58:58 +0200');
  </code></pre>
  
  <p>Here is the code which doesn't work:</p>
  
  <pre><code>    $.getJSON('./timesheet.json', function(data){
  
          context.tasks = data;
  
          for (var prop in context.tasks){
  
              var startTime = new Date(context.tasks[prop].start);
  
              console.log(startTime); // Invalid Date
              console.log(context.tasks[prop].start); // 2015-08-28 02:41:02 +0200
  
              var endTime = new Date(context.tasks[prop].end);
  
              var diff = endTime.getTime() - startTime.getTime(); // this doesn't work as endTime and startTime are not Date objects!
              cosole.log(diff); // yields NaN
          }
          var html = template(context);
  
          $('.tasklist').append(html);
      });
  </code></pre>