Algorithm Math Delphi

Title: How to find the number of days in actual month
function DaysInMonth: Integer;
var
Year, Month, Day: Word;
begin
DecodeDate(Now, Year, Month, Day);
Result := MonthDays[IsLeapYear(Year), Month];
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IntToStr(DaysInMonth));
end;