[TRUCO DELPHI] Dar formato de Segundos a (hh:mm:ss).
Declaracion de algunas Constantes.
delphi
const SecPerDay = 86400; SecPerHour = 3600; SecPerMinute = 60;
delphi
function SecondToTime(const Seconds: Cardinal): Double; var ms, ss, mm, hh, dd: Cardinal; begin dd := Seconds div SecPerDay; hh := (Seconds mod SecPerDay) div SecPerHour; mm := ((Seconds mod SecPerDay) mod SecPerHour) div SecPerMinute; ss := ((Seconds mod SecPerDay) mod SecPerHour) mod SecPerMinute; ms := 0; Result := dd + EncodeTime(hh, mm, ss, ms); end;
Ejemplo de uso:
delphi
procedure TForm1.Button1Click(Sender: TObject); begin label1.Caption := DateTimeToStr(Date + SecondToTime(86543)); end;
Saludos!