The MonthDays constant is a useful part of the SysUtils unit. It gives the number of days in a month, with 29 returned for February if the year is a leap year (Boolean first array parameter). This is best understood by looking at the sample code.
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate.
unit Unit1;
interface
uses SysUtils, // Unit containing the MonthDays command Forms, Dialogs;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end;
var Form1: TForm1;
implementation {$R *.dfm} // Include form definitions
procedure TForm1.FormCreate(Sender: TObject); begin // How many days in February 2000 ?
ShowMessage('Days in February 2000 = '+
IntToStr(MonthDays[IsLeapYear(2000)][2]));
end;