DelphiBasics
IsLeapYear
Function
Returns true if a given calendar year is a leap year SysUtils unit
 function IsLeapYear ( const Year : Word ) : Boolean;
Description
The IsLeapYear function returns true if a given calendar value is a leap year.
 
Year can have a value 0..9999
Related commands
DayOfTheYear Gives the day of the year for a TDateTime value (ISO 8601)
DaysInAYear Gives the number of days in a year
MonthDays Gives the number of days in a month
MonthOfTheYear Gives the month of the year for a TDateTime value
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Was the year 2000 a leap year?
// 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 IsLeapYear 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
  if IsLeapYear(2000)
  then ShowMessage('2000 was a leap year')
  else ShowMessage('2000 was not a leap year');
end;
 
end.
Hide full unit code
   2000 was a leap year
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page