title: Convert time-string to std::time_t using std::get_time: wrong result
body: <p>I am trying to sort photos in chronological order. Therefore I extract the time as a string from the EXIF data, which I then convert to <code>std::time_t</code>. However I sometimes get an incorrect result. I have reduced the problem to this minimal example. It features three time-strings, one second apart:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;ctime&gt;
  #include &lt;iomanip&gt;
  #include &lt;sstream&gt;
  
  int main()
  {
    std::vector&lt;std::string&gt; vec;
  
    vec.push_back("2016:07:30 09:27:06");
    vec.push_back("2016:07:30 09:27:07");
    vec.push_back("2016:07:30 09:27:08");
  
    for ( auto &amp; i : vec )
    {
      struct std::tm tm;
      std::istringstream iss;
      iss.str(i);
      iss &gt;&gt; std::get_time(&amp;tm,"%Y:%m:%d %H:%M:%S");
  
      std::time_t time = mktime(&amp;tm);
  
      std::cout &lt;&lt; i &lt;&lt; " time = " &lt;&lt; time &lt;&lt; std::endl;
    }
  }
  </code></pre>
  
  <p>Compiled with <code>clang++ -std=c++14 test.cpp</code>.</p>
  
  <p>The output:</p>
  
  <pre><code>2016:07:30 09:27:06 time = 1469867226
  2016:07:30 09:27:07 time = 1469863627
  2016:07:30 09:27:08 time = 1469863628
  </code></pre>
  
  <p>Which is obviously wrong, they should be <code>1</code> apart, which is only true for the last two?</p>
  
  <blockquote>
    <p><strong>Edit</strong></p>
    
    <p>Since there seems to be a bug in clang's <code>std::get_time</code> (and <code>std::put_time</code>), here is my version information: </p>
  
  <pre><code>$ clang --version
  Apple LLVM version 8.1.0 (clang-802.0.42)
  Target: x86_64-apple-darwin16.7.0
  Thread model: posix
  InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  </code></pre>
  </blockquote>