function BuffTextEqualAsm(const Str1, Str2: PChar; MaxLen: Cardinal): Boolean; assembler;
asm
PUSH EDI
PUSH ESI
PUSH EBX
MOV EDI,EDX
MOV ESI,EAX
MOV EBX,ECX
XOR EAX,EAX
OR ECX,ECX
JE @@T
REPNE SCASB
SUB EBX,ECX
MOV ECX,EBX
MOV EDI,EDX
XOR EDX,EDX
@@1:
REPE CMPSB
JE @@T
MOV AL,[ESI-1]
CMP AL,'a'
JB @@2
CMP AL,'z'
JA @@2
SUB AL,20H
@@2:
MOV DL,[EDI-1]
CMP DL,'a'
JB @@3
CMP DL,'z'
JA @@3
SUB DL,20H
@@3:
SUB EAX,EDX
JE @@1
@@F:
xor EAX,EAX
jmp @@E
@@T:
mov EAX,1
@@E:
POP EBX
POP ESI
POP EDI
end;
function IndexedWithToken(const Src: String;const Index: Integer;Token:String = ','): String;
var
P, Start : PChar;
tkLength : Integer;
LocalIndex : Integer;
begin
Result := '';
LocalIndex := 1;
tkLength := Length(Token);
P := Pointer(Src);
Start := P;
if Index <= 0 then Exit;
if P <> nil then begin
while P^ <> #0 do
begin
while Not ((P^ In [#0]) or BuffTextEqualAsm(P,Pointer(Token),tkLength)) do Inc(P);
if P <> Start then
begin
if LocalIndex = Index then
begin
SetString(Result, Start, Integer(P - Start));
Exit;
end;
end;
if P^ = #0 then break;
Inc(LocalIndex);
Inc(P,tkLength);
Start := P;
end;
end;
if P <> Start then
begin
if LocalIndex = Index then
begin
SetString(Result, Start, Integer(P - Start));
Exit;
end;
end;
end;
function GetValidDateTime(Datestr: string): TDateTime;
var
Mon: string;
i: Integer;
st: string;
const
MyMonth: array[1..12] of string=('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec');
begin
Mon := IndexedWithToken(Datestr,3,' ');
st := IndexedWithToken(Datestr,4,' ') + '-';
for i := 1 to 12 do
if CompareText(Mon,MyMonth[i]) = 0 then
begin
st := st + IntToStr(i);
break;
end;
st := st + '-'+ IndexedWithToken(Datestr,2,' ') + ' '+IndexedWithToken(Datestr,5,' ');
result := StrToDateTime(st) + 1/3;
end;