Skip to content

IsInLeapYear ​

The IsInLeapYear function returns True if specified TDateTime value represented by AValue occurs in a leap year. The year is a calendar year.

Declaration: function IsInLeapYear(const AValue: TDateTime): Boolean;

Example

pascal
procedure OnMapEvent(var Value:Variant);
var
  IsLeap : boolean;
begin
 //If the year for NOW() is 2023, then it is NOT a leap year
  IsLeap := IsInLeapYear(Now);
 if IsLeap = True then
    Loginfo('This year is a leap year.')
 else
    LogInfo('This year is NOT a keap year.');
  LogInfo('');

 //If the year for NOW()+1 is 2024, then it IS a leap year
  IsLeap := IsInLeapYear(IncYear(Now, 1));   //Increments the year value by one
 if IsLeap = True then
    Loginfo('This year is a leap year.')
 else
    LogInfo('This year is NOT a keap year.');
  LogInfo('');
end;