FYI, the SysUtils unit has an IsLeapYear() function, and a MonthDays[] array, eg:
uses
..., SysUtils;
function DaysInMonth(Mo, Yr : Word): Word;
begin
Result := MonthDays[IsLeapYear(Yr), Mo];
end;
Alternatively, the DateUtils unit has its own DaysInAMonth() function, eg:
uses
..., DateUtils;
function DaysInMonth(Mo, Yr : Word): Word;
begin
Result := DateUtils.DaysInAMonth(Yr, Mo);
end;
No need to reinvent the wheel here...