whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

34 Visitors Online


 
...use TTime with over 24 hours?
Autor: Zandy
[ Print tip ]  

Tip Rating (3):  
     


function TextToTime(S: string): Integer;
var
  
p, i: Integer;
  Sh, Sm, Ss: string;
begin
  
Sh := '';
  SM := '';
  SS := '';
  i  := 1;
  p  := 0;
  while do
  begin
    if 
(s[i] <> ':') then
    begin
      case 
of
        
0: SH := Sh + s[i];
        1: SM := SM + S[i];
        2: SS := SS + S[i];
      end;
    end
    else
      
Inc(p);
    Inc(i);
  end;
  try
    
Result := (StrToInt(SH) * 3600) + (StrToInt(SM) * 60) + (StrToInt(SS))
    except
      
Result := 0;
  end;
end;

function TimeToText(T: Integer): string;
var
  
H, M, S: string;
  ZH, ZM, ZS: Integer;
begin
  
ZH := T div 3600;
  ZM := T div 60 - ZH * 60;
  ZS := T - (ZH * 3600 + ZM * 60);
  if ZH then H := '0' + IntToStr(ZH)
  else
    
H := IntToStr(ZH);
  if ZM then M := '0' + IntToStr(ZM)
  else
    
M := IntToStr(ZM);
  if ZS then S := '0' + IntToStr(ZS)
  else
    
S := IntToStr(ZS);
  Result := H + ':' + M + ':' + S;
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners