IsLeapYear Routines
Is given Year a Leap Year.

Unit
QESBPCSDateTime

Overloaded Variants
Function IsLeapYear(const Year: Word): Boolean;
Function IsLeapYear(const Year: Integer): Boolean;
Function IsLeapYear(const DT: TDateTime): Boolean;

Declaration
Function IsLeapYear(const Year: Word): Boolean;

Description
Thanks to Dr John Stockton for suggesting a faster methodology.

Parameters
Year the Year to be processed - should be 4 digit, eg 1999.
DT the Date to be processed.

Category
Date/Time Arithmetic Routines
Year Based Arithmetic Routines
Date/Time Comparison

Implementation

function IsLeapYear (const Year: Word): Boolean;
begin
     Result := ((Year and 3) = 0) and ((Year mod 100 > 0) or (Year mod 400 = 0))
End;

Declaration
Function IsLeapYear(const Year: Integer): Boolean;

Implementation

function IsLeapYear (const Year: Integer): Boolean;
begin
     Result := ((Year and 3) = 0) and ((Year mod 100 > 0) or (Year mod 400 = 0))
End;

Declaration
Function IsLeapYear(const DT: TDateTime): Boolean;

Implementation

function IsLeapYear (const DT: TDateTime): Boolean;
begin
     Result := IsLeapYear (Date2Year (DT));
End;


HTML generated by Time2HELP
http://www.time2help.com