title: Inconsistent results with get_time
body: <p>The program:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;iomanip&gt;
  
  int main()
  {
      std::string time_str = &quot;2017-01-03 09:30:00&quot;;
      for(int i=0; i&lt;5; i++)
      {
          std::istringstream ss(time_str);
          std::tm tm;
          ss &gt;&gt; std::get_time(&amp;tm, &quot;%Y-%m-%d %H:%M:%S&quot;);
          time_t t = std::mktime(&amp;tm);
          std::cout &lt;&lt; (int)t &lt;&lt; &quot; &quot; &lt;&lt; tm.tm_hour &lt;&lt; std::endl;
      }
  }
  </code></pre>
  <p>This program has inconsistent behavior. On my local machine with MinGW 8.1.0, it prints</p>
  <pre><code>1483453800 8
  1483457400 9
  1483457400 9
  1483457400 9
  1483457400 9 
  </code></pre>
  <p>On Ideone, on both their Clang and GCC compilers, it prints</p>
  <pre><code>-1 9
  -1 9
  -1 9
  -1 9
  -1 9
  </code></pre>
  <p>What's up with this behavior? The Ideone output, which returns &quot;-1&quot; for time_t, suggests that I am messing up somewhere. The MinGW output, however, is even stranger because the first iteration of the loop has a different result from all the other iterations. My compiler and flags are in the comments.</p>
  <p>Some other odd behavior is that if I change time_str to &quot;1970-01-01 00:00:00&quot;, I get</p>
  <pre><code>18000 23
  21600 0
  21600 0
  21600 0
  21600 0
  </code></pre>
  <p>which is really weird both due to inconsistency and because epoch is stored as either 18000 or 21600 seconds instead of 0.</p>