title: DateTimeToUnix in UTC?
body: <p>I need UTC variants of the functions <code>DateTimeToUnix</code> and <code>UnixToDateTime</code>, so a Chinese customer is able to interact with the server in Germany. Both sides should be able to exchange Unix timestamps (in UTC, without DST) and be able to communicate through this way.</p>
  
  <p>In a <a href="https://code.google.com/p/heidisql/issues/detail?id=2507#c3" rel="nofollow">bugreport of HeidiSQL</a> , users discussed that <code>DateTimeToUnix</code> and <code>UnixToDateTime</code> do not care about the time zone, and there I have found following code:</p>
  
  <pre><code>function DateTimeToUTC(dt: TDateTime): Int64;
  var
    tzi: TTimeZoneInformation;
  begin
    Result := DateTimeToUnix(dt);
    GetTimeZoneInformation(tzi);
    Result := Result + tzi.Bias * 60;
  end;
  </code></pre>
  
  <p>MSDN <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms724421%28v=vs.85%29.aspx" rel="nofollow">explains</a> <code>twi.Bias</code> as follows:</p>
  
  <blockquote>
    <p>All translations between UTC time and local time are based on the following formula:</p>
    
    <p>UTC = local time + bias</p>
    
    <p>The bias is the difference, in minutes, between UTC time and local time.</p>
  </blockquote>
  
  <p>This sounds logical, but since I was unsure if the code above was correct, I made following program to check it:</p>
  
  <pre><code>// A date in summer time (DST)
  Memo1.Lines.add('1401494400'); // 31 May 2014 00:00:00 GMT according to http://www.epochconverter.com/
  Memo1.Lines.add(inttostr(DateTimeToUnixUTC(StrToDate('31.05.2014'))));
  
  // A date in winter time
  Memo1.Lines.add('567302400'); // 24 Dec 1987 00:00:00 GMT according to http://www.epochconverter.com/
  Memo1.Lines.add(inttostr(DateTimeToUnixUTC(StrToDate('24.12.1987'))));
  </code></pre>
  
  <p>The output in Germany (GMT+1+DST) is currently:</p>
  
  <pre><code>1401494400
  1401490800
  567302400
  567298800
  </code></pre>
  
  <p>I expected the output being:</p>
  
  <pre><code>1401494400
  1401494400
  567302400
  567302400
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>PS: For this project I am bound to Delphi 6.</p>