[code lang=”delphi”]// First we need to create a record
type TimeParse = record
timeDay : Integer;
timeHour : Integer;
timeMin : Integer;
timeSec : Integer;
end;
// Now here is the function
function TForm1.DoTime(TheSeconds : Integer) : TimeParse;
begin
Result.timeHour := 0;
Result.timeMin := 0;
Result.timeDay := 0;
Result.timeSec := 0;
// Get days
While TickVal > 86399 Do
Begin
Result.timeDay := Result.timeDay+ 1;
TickVal := TickVal – 86400;
End;
// Get hours
While TickVal > 3599 Do
Begin
Result.timeHour := Result.timeHour + 1;
TickVal := TickVal – 3600;
End;
// Get minutes
While TickVal > 59 Do
Begin
Result.timeMin := Result.timeMin + 1;
TickVal := TickVal – 3600;
End;
// Whats left over are seconds
Result.timeSec := TickVal;
end;
//Call it like this
Var
FTimeParse : TimeParse;
begin
FTimeParse := DoTime(tmpTime);
end;
[/code]
[tags]Delphi, Misc, DateTime[/tags]
0 Kommentare zu “DateTime: Time Parse”