初学者(代码改错)

菜鸟求助(代码改错)
做的是一个日期计算的,比如2008年9月8日和2009年4月4日相差多少年多少月多少日。
就有一个"计算日期"按钮。
但是小弟编的代码错误百出,请高手指正,很感谢
下面是代码:
unit work1;

interface

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

type
  TForm1 = class(TForm)
  Label1: TLabel;
  Label2: TLabel;
  Label3: TLabel;
  Label4: TLabel;
  Label5: TLabel;
  Label6: TLabel;
  Label7: TLabel;
  Label8: TLabel;
  Label9: TLabel;
  Edit1: TEdit;
  Edit2: TEdit;
  Edit3: TEdit;
  Edit4: TEdit;
  Edit5: TEdit;
  Edit6: TEdit;
  Button1: TButton;
  Edit7: TEdit;
  procedure Button1Click(Sender: TObject);
  private
  { Private declarations }
  public
  { Public declarations }
  end;

var
  Form1: TForm1;

implementation

var
  date1:string;
  date2:string;
  temp1:string;
  temp2:string;
  temp3:string;
  day1:integer;
  day2:integer;
  y1:integer;
  y2:integer;
  m1:integer;
  m2:integer;
  d1:integer;
  d2:integer;
  n:integer;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  date1:=edit1.text+edit2.text+edit3.text;
  date2:=edit4.text+edit5.text+edit6.text;
  y1:=strtoint(edit1.text);y2:=strtoint(edit4.text);
  m1:=strtoint(edit2.text);m2:=strtoint(edit5.text);
  d1:=strtoint(edit3.text);d2:=strtoint(edit6.text);
  day1:=strtoint(date1);day2:=strtoint(date2);
  if (y1 mod 400 =0) or ((y1 mod 100<>0) and (y1 mod 4=0)) then
  begin
  n:=1;
  end
  else
  n:=2;
  end ;
  if day1 <= day2 then
  begin
  if(m1<=m2) then
  begin
  if(d1<=d2) then
  begin
  temp1:=inttostr(y2-y1);
  temp2:=inttostr(m2-m1);
  temp3:=inttostr(d2-d1);
  end
  else
  temp1:=inttostr(y2-y1);
  temp2:=inttostr(m2-m1-1);
  case m1 of
  1: temp3:=inttostr(d2-d1+31);
  2: if n=1 then
  begin
  temp3:=inttostr(d2-d1+29);
  end
  else
  temp3:=inttostr(d2-d1+28);
  end;
  3: temp3:=inttostr(d2-d1+31);
  4: temp3:=inttostr(d2-d1+30);
  5: temp3:=inttostr(d2-d1+31);
  6: temp3:=inttostr(d2-d1+30);
  7: temp3:=inttostr(d2-d1+31);
  8: temp3:=inttostr(d2-d1+31);
  9: temp3:=inttostr(d2-d1+30);
  10: temp3:=inttostr(d2-d1+31);
  11: temp3:=inttostr(d2-d1+30);
  12: temp3:=inttostr(d2-d1+31);
  end;
  end
  else
  if(d1<=d2) then
  begin
  temp1:=inttostr(y2-y1-1);
  temp2:=inttostr(m2-m1+12);
  temp3:=inttostr(d2-d1);
  end
  else
  temp1:=inttostr(y2-y1-1);
  temp2:=inttostr(m2-m1+11);
  case m1 of