title: Unit testing handling of date inputs in JavaScript regardless of time zone
body: <p>I have a form where a user can enter a date, i.e. <code>&lt;input type="date"&gt;</code> the value is submitted in <code>yyyy-MM-dd</code> format. When I create a <em>Date</em> object with the string it assumes the time zone is the one the user's browser is set to – this <em>is</em> the behavior I want.</p>
  
  <p>I'm then using the date value to make queries against a REST API that expects ISO date/time strings. That's no problem as the <code>toISOString</code> function on the <em>Date</em> object handles everything correctly.</p>
  
  <p>However, when I'm unit testing this code – setting my input to a <code>yyyy-MM-dd</code> string then asserting that the output is an expected ISO timestamp string the tests can only work in a particular time zone. Is there a way I can force the time zone in the test?</p>
  
  <p>I've tried using Jasmine spies to do something like:</p>
  
  <pre><code>var fixedTime = moment().zone(60).toDate()
  spyOn(window, 'Date').andCallFake(function() {
      return fixedTime;
  });
  </code></pre>
  
  <p>But given there are so many variants of the constructor and so many ways it gets called by moment.js this is pretty impractical and is getting me into infinite loops.</p>