title: How can a Windows DATE be converted into a Unix time in c++
body: <p>Windows uses the <a href="https://msdn.microsoft.com/en-us/library/82ab7w69.aspx" rel="nofollow"><code>DATE</code></a> type to represent dates. This is a <code>double</code> value representing the number of days since 30 December 1899, midnight.</p>
  
  <p>How can a <code>DATE</code> be converted into a Unix timestamp (the number of seconds since 01 January 1970) value?</p>
  
  <p>Specifically, how can this be achieved using only the c++ standard library, and windows libraries for which MinGW distributes header files?</p>
  
  <p>For example, I can get a date property from an <code>IShellFolder2</code>:</p>
  
  <pre><code>void MyFunc(IShellFolder2 *folder, PCUITEMID_CHILD pidl, const SHCOLUMNID *columnid) {
      VARIANT* v = (VARIANT*) malloc(sizeof(VARIANT));
      DATE d;
      HRESULT hr = folder-&gt;GetDetailsEx(pidl, colid, v);
      if (SUCCEEDED(hr)) {
          hr = VariantChangeType(v, v, 0, VT_DATE);
          if (SUCCEEDED(hr)) {
               d = v-&gt;date;
          }
          VariantClear(v);
      }
      free(v);
      // process date here
  }
  </code></pre>
  
  <p>How do I then transform this value for use with software that uses the Unix timestamp format?</p>
  
  <p>Currently used header files (not all relevant to this specific issue):</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;tchar.h&gt;
  #include &lt;shlobj.h&gt;
  #include &lt;shlwapi.h&gt;
  #include &lt;propkey.h&gt;
  #include &lt;wchar.h&gt;
  #include &lt;shlguid.h&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  </code></pre>