(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
program unixtime;

{$APPTYPE CONSOLE}

uses
  SysUtils, Windows;

function time(t : pointer) : integer; cdecl; external 'msvcrt.dll';

function D2U(Value: TDateTime): LongWord;

var
  tz : TTimeZoneInformation;
  res : LongWord;

begin
  res := trunc((value - StrToDateTime('01-01-1970 00:00:00')) * 24 * 60 * 60);
  if GetTimeZoneInformation(tz) = TIME_ZONE_ID_DAYLIGHT then begin
    res := res + (tz.DaylightBias + tz.Bias) * 60
  end else begin
    res := res + (tz.StandardBias + tz.Bias) * 60;
  end;
  D2U := res;
end;

var
  t : TDateTime;

begin
  writeln(D2U(now));
  writeln(time(nil));
end.
