Skip to content

IsValidDateDay ​

IsValidDateDay returns True if the given year and day of the year represent components of a valid date.

  • AYear must be within the range of 1 through 9999 inclusive.
  • ADayOfYear must fall within the range of 1 through to 366 - depending on the total number of days in AYear - whether it is a leap year or not.

January 1st is considered to be day 1, January 2nd is day 2 e.t.c.

Declaration: Function IsValidDateDay(const AYear, ADayOfYear: Word): Boolean;

An example of its use follows.

pascal
procedure OnMapEvent(var Value:Variant);
var
  TheYear, TheDay : word;
begin
 //Returns true if the given YEAR and DAY are valid date components

 //VALID parts
  TheDay := 290;
  TheYear := 2023;
 If IsValidDateDay(TheYear, TheDay) then
    Loginfo('YAHOO!!! The Day date is valid.')
 else
    LogInfo('OOPS!! The Day date is not valid.');

 //INVALID parts . ... there are not 400 days in a year!
  TheDay := 400;
  TheYear := 2023;
 If IsValidDateDay(TheYear, TheDay) then
    Loginfo('YAHOO!!! The Day date is valid.')
 else
    LogInfo('OOPS!! The Day date is not valid.');

  LogInfo('');
end;