You are not logged in.
Pages: 1
Hello,
I am using Delphi 10.3.3.
I probably used wrong selection of words using google. SynCommons.pas seems not having that function.
I am searching for a faster running code than current System.SysUtils.StrToDate().
There is below function in my code base and when I used a profiler, it turned out to be time consuming function in the application (most likely because mos of the calls are raising exception I think but not sure).
function IsDate(const DateString: string): Boolean;
begin
try
StrToDate(DateString);
Result := True;
except
Result := False;
end;
end;
So, I am searching for a faster executing code than above.
Offline
You can use TryStrToDate() from SysUtils.pas (IIRC): it won't raise any exception, so it will be much faster if the supplied text is not a valid date.
But there are so many date format around, that there is no easy replacement...
In SynCommons.pas we have ISO-8601 very fast conversion functions, e.g. IsIso8601() or Iso8601ToTimeLogPUTF8Char() - which work from UTF-8 text.
You can write your own function from their code.
Offline
Pages: 1