leap year |
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;
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;
No comments:
Post a Comment