Skip to content

IsValidTime ​

This function returns True if the given time parts would return a valid time.

With a similar functionality to IsValidDate, this function is useful for testing time parts prior to passing them to the EncodeDateTime function.

Declaration: function IsValidTime(const AHour: Word; const AMinute: Word; const ASecond: Word; const AMilliSecond: Word): Boolean

An example of code using this function.

pascal
procedure OnMapEvent(var Value:Variant);
var
  vReal, vReal2 ; boolean;
begin
 //Returns true if the given time parts would create a valid time

  vReal := IsValidTime(15, 45, 23, 562);                   //VALID
 if vReal = True then
    loginfo('vReal time is valid.')
 else
    LogInfo('vReal time is not valid.');

  vReal2 := IsValidTime(15, 71, 61, 562);                   //INVALID
 if vReal2 = True then
    loginfo('vReal2 time is valid.')
 else
    LogInfo('vReal2 time is not valid.');

  LogInfo('');
end;