function ConvertTimeToTimestr(aTimePos,aTimeLen:longInt;RestTime,AutoHour,ShowMS,UseColon:boolean):string; var vHou,vMin,vSec:integer; vSecR:real; sHou,sMin,sSec:string;
isFu:boolean;//该时间 是否为负
lbstr:string; begin vHou:=0; isFu:= ( aTimePos<0) ; lbStr:='; if isFu and Not RestTime then begin aTimePos:=-aTimePos; lbStr:='-'; end;
if not RestTime then begin if aTimePos> 3600000 then begin vHou:=trunc(aTimePos / 3600000) ; vMin:=trunc((aTimePos-vHou*3600000) / 60000); vSec:=trunc((aTimePos-vHou*3600000-vMin*60000) / 1000); vSecR:=(aTimePos-vHou*3600000-vMin*60000) / 1000; end else begin vMin:=trunc(aTimePos / 60000); vSec:=trunc((aTimePos-vMin*60000) / 1000); vSecR:=(aTimePos-vMin*60000) / 1000; end; end else // 剩余时间 begin if aTimeLen-aTimePos > 3600000 then begin vHou:=trunc((aTimeLen-aTimePos) / 3600000) ; vMin:=trunc(((aTimeLen-aTimePos)-vHou*3600000) / 60000); vSec:=trunc(((aTimeLen-aTimePos)-vHou*3600000-vMin*60000) / 1000); vSecR:=((aTimeLen-aTimePos)-vHou*3600000-vMin*60000) / 1000; end else begin vMin:=trunc((aTimeLen-aTimePos) / 60000); vSec:=trunc(((aTimeLen-aTimePos)-vMin*60000) / 1000); vSecR:=((aTimeLen-aTimePos)-vMin*60000) / 1000; end; end;
if vHou<>0 then sHou:= formatstr(inttostr(vHou),2,true,false) else sHou:=';
sMin:= formatstr(inttostr(vMin),2,true,false);
if ShowMS then //是否显示 毫秒 sSec:= formatfloat('00.000',vSecR) else sSec:= formatstr(inttostr(vSec),2,true,false);
if UseColon then begin if AutoHour then begin if shou<>' then result:=lbStr + sHou+':'+sMin+':'+sSec else result:=lbStr + sMin+':'+sSec end else result:=lbStr + sHou+':'+sMin+':'+sSec; end else begin if AutoHour then begin if shou<>' then result:=lbStr + inttostr(strtoInt(sHou))+'时'+inttostr(strtoInt(sMin))+'分'+inttostr(strtoInt(sSec))+'秒' else result:=lbStr + inttostr(strtoInt(sMin))+'分'+inttostr(strtoInt(sSec))+'秒' end else result:=lbStr + inttostr(strtoInt(sHou))+'时'+inttostr(strtoInt(sMin))+'分'+inttostr(strtoInt(sSec))+'秒'; end;