任意月份天数
procedure TForm1.Button1Click(Sender: TObject);
var
MyDate : TDateTime;
tmpStr : String;
tmpInt : Integer;
begin
MyDate := Date() + 365 - (30*5);
tmpStr := FormatDateTime('mmmm yyyy',MyDate);
tmpInt := DaysInMonth(MyDate);
ShowMessage(tmpStr + '有 ' + IntToStr(tmpInt) + '天');
end;
function TForm1.DaysInMonth(ADate:TDateTime):Integer;
var
MyMonth,
MyYear,
MyDay : Word;
MyDayTable : TDayTable;
tmpBool : Boolean;
begin
DecodeDate(ADate, MyYear, MyMonth, MyDay);
tmpBool := IsLeapYear(MyYear);
MyDayTable := MonthDays[tmpBool];
Result := MyDayTable[MyMonth];
end;