Delphi 10.4
I need to check if the last 8 or 10 characters of a string fit a date mask. I would like to do this using only pure Delphi code. Any ideas?
Examples of data:
Docket 05/04/98
Docket 12/11/2021
Something like
if DocumentName <> '' then
begin
//* Test for date as part of the document name and remove it if it is.
if IsDateMask(RStr(DocumentName,8),'00|/00|/00',-1) then
DocumentName := Copy(DocumentName,1,length(DocumentName)-9)
else
if IsDateMask(RStr(DocumentName,10),'00|/00|/0000',-1) then
DocumentName := Copy(DocumentName,1,length(DocumentName)-11);
...
end;
2/29/2003
and0/55/72
wouldn't be legal). And expect US (m/d/yyyy) versus UK (dd/mm/yyyy). The delimiter is also important (i.e.d.m.yyyy
oryyyy-mm-dd
).