(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function timeadd(t1, t2 : string) : string;

var
  h1,m1,s1 : integer;
  h2,m2,s2 : integer;
  h3,m3,s3 : integer;

begin
  h1 := StrToInt(Copy(t1, 1, 2));
  m1 := StrToInt(Copy(t1, 4, 2));
  s1 := StrToInt(Copy(t1, 7, 2));
  h2 := StrToInt(Copy(t2, 1, 2));
  m2 := StrToInt(Copy(t2, 4, 2));
  s2 := StrToInt(Copy(t2, 7, 2));
  s3 := s1 + s2;
  m3 := m1 + m2;
  h3 := h1 + h2;
  if s3 >= 60 then begin
    s3 := s3 - 60;
    m3 := m3 + 1;
  end;
  if m3 >= 60 then begin
    m3 := m3 - 60;
    h3 := h3 + 1;
  end;
  result := '';
  if h3 < 10 then
    result := result + '0' + IntToStr(h3)
  else
    result := result + IntToStr(h3);
  result := result + ':';
  if m3 < 10 then
    result := result + '0' + IntToStr(m3)
  else
    result := result + IntToStr(m3);
  result := result + ':';
  if s3 < 10 then
    result := result + '0' + IntToStr(s3)
  else
    result := result + IntToStr(s3);
end;

procedure TForm1.Button1Click(Sender: TObject);

begin
  Edit3.Text := timeadd(Edit1.Text, Edit2.Text);
end;

end.
