My best score is 67 kb after strip -s with the code below ... ;-)

Of course it will not work on every  version of Windows.

program uptime;

function GetTickCount64: QWord; stdcall; external 'kernel32.dll';

function _2d( _i: Integer): String;
begin
     Str( _i, Result);
     if Length(Result) < 2 then Result:= '0'+Result;

end;

function FormatUpTime( _tc: QWord): String;
var
   t, d, h, m, s: Integer;
   sd: String;
begin
     t:= _tc div 1000;
     s:= t mod 60;
     m:= (t div 60) mod 60;
     h:= (t div 3600) mod 24;
     d:= (t div 86400);

     Result:= _2d(h)+':'+_2d( m)+':'+_2d( s);
     if 0 = d then exit;

     Str( d, sd);
     Result:= sd+' '+Result;
end;

begin
     WriteLn( FormatUpTime( GetTickCount64));
end.


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to