--> Leap Year check with delphi | Delphi Tips Trick

For Newbie

Tuesday 15 November 2011

Leap Year check with delphi

| Tuesday 15 November 2011


leap year
Leap Year check with delphi


Functions that can be used:


function IsLeapYear(Year: Word): Boolean;


Example of use:



if isLeapYear(2020) then ShowMessage('Yes') else ShowMessage('No');


You can create new functions to determine whether a leap year by TDate.
leapByDate function (const DT: TDate): Boolean;
var
   d, m, y: Word;
begin
   DecodeDate (DT, y, m, d);
   Result: = isLeapYear (y);
end;

Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
begin
   if leapByDate (DateTimePicker1.Date) then ShowMessage ('Yes') else
     ShowMessage ('Not');
end;

Related Posts

No comments: