function FechaAMano(Fecha: String): TDate;
var
Expresión: TRegExpr;
Pos: Integer;
NuevaFecha: String;
begin
Expresión:=TRegExpr.Create;
Expresión.Expression:='\d\d*.*(ENERO|FEBRERO|MARZO|ABRIL|MAYO|JUNIO|JULIO|AGOSTO|SEP?TIEMBRE|OBTUBRE |NOVIEMBRE|DICIEMBRE).*\d{2}';
Fecha:=UpperCase(Fecha);
Fecha:=ReplaceStr(Fecha,'SETIEMBRE','SEPTIEMBRE');
if Expresión.Exec(Fecha) then begin
Expresión.Expression:='\d\d*';
Expresión.Exec(Fecha);
NuevaFecha:=Copy(Fecha,Expresión.MatchPos[0],Expresión.MatchLen[0])+'/';
Expresión.Expression:='(ENERO|FEBRERO|MARZO|ABRIL|MAYO|JUNIO|JULIO|AGOSTO|SEP?TIEMBRE|OBTUBRE|NOVIEM BRE|DICIEMBRE)';
Expresión.Exec(Fecha);
NuevaFecha := NuevaFecha+IntToStr(StringToCaseSelect(Copy(Fecha,Expresión.MatchPos[0],Expresión.MatchLen[0]),['ENERO','FEBRERO','MARZO','ABRIL','MAYO','JUNIO','JULIO','AGOSTO','SEPTIEMBRE','OBTUBRE','NOVIEMBRE' ,'DICIEMBRE'])+1)+'/';
Fecha:=Copy(Fecha,Expresión.MatchPos[0]+Expresión.MatchLen[0],Length(Fecha));
Expresión.Expression:='\d\d*'; Expresión.Exec(Fecha);
NuevaFecha:=NuevaFecha+Copy(Fecha,Expresión.MatchPos[0],Expresión.MatchLen[0]);
Result:=StrToDate(NuevaFecha);
end else begin
Expresión.Expression:='(\d{1}|\d{2})(-|/)(\d{1}|\d{2})(-|/)\d{2}';
if Expresión.Exec(Fecha) then begin
Fecha:=ReplaceStr(Fecha,'-','/');
Result:=StrToDate(Fecha);
end else
Result:=0;
end;
Expresión.Free;
end;
function StringToCaseSelect(Selector: String; Opciones: array of String): Integer;
var
i: Integer;
begin
Result:=-1;
for i:=0 to Length(Opciones)-1 do
begin
if CompareText(Selector,Opciones[i]) = 0 then
begin
Result:=i;
break;
end;
end;
end;