Appearance
DaysInYear
The function DaysInYear returns the number of days in the year that has been specified by the given date, and can be used to determine whether the specified year is a leap year or not.
Declaration: function DaysInYear(const AValue: TDateTime): Word;
The following example shows several ways of achieving and displaying a result.
pascal
procedure OnMapEvent(var Value:Variant);
var
vDIY : word;
vYear : TDateTime;
vStrYear : string;
begin
vDIY := DaysInYear(Date);
LogInfo(IntToStr(vDIY));
//NOT a leap year so 365 days
vStrYear := '12-12-2022';
vYear := StringToDateTime('dd/mm/yyyy',vStrYear);
vDIY := DaysInYear(vYear);
LogInfo(IntToStr(vDIY));
//A leap year so 366 days
vStrYear := '12-12-2024';
vYear := StringToDateTime('dd/mm/yyyy',vStrYear);
vDIY := DaysInYear(vYear);
LogInfo(IntToStr(vDIY));
LogInfo('');
end;
