function DaysOfMonth(mm, yy: Integer): Integer; begin
if mm = 2 then
begin Result := 28; if IsLeapYear(yy) then Result := 29; end
else
begin
if mm < 8 then
begin
if (mm mod 2) = 0 then Result := 30 else Result := 31; end
else
begin
if (mm mod 2) = 0 then Result := 31 else Result := 30; end; end; end;
procedure TForm1.Button1Click(Sender: TObject); var days: Integer; begin days := DaysOfMonth(7, 2001);
ShowMessage('July 2001 has ' + IntToStr(days) + ' days'); end;