System.DateUtils 2. IsInLeapYear 判断是否是闰年

时间:2023-03-09 15:04:07
System.DateUtils 2. IsInLeapYear 判断是否是闰年

编译版本:Delphi XE7

function IsInLeapYear(const AValue: TDateTime): Boolean;

implementation

// 判断是否是闰年

function IsInLeapYear(const AValue: TDateTime): Boolean;
begin
  Result := IsLeapYear(YearOf(AValue));
end;

// 是否是闰年,引用单元 System.SysUtils

function IsLeapYear(Year: Word): Boolean;
begin
  Result := (Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 400 = 0)); // 此处为老生常谈,不再赘述
end;