闰年
function dateLeapYear(D: TDateTime): Boolean;
var
Year,Month,Day: Word;
begin
DecodeDate(D,Year,Month,Day);
Result:=(Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 400 = 0));
end;
function dateDaysInMonth(D: TDateTime): Integer;
const
DaysPerMonth: array[1..12] of Byte= (31,28,31,30,31,30,31,31,30,31,30,31);
var
Month: Integer;
begin
Month:=dateMonth(D);
Result:=DaysPerMonth[Month];
if (Month=2) and dateLeapYear(D) then Inc(Result);
end;