function ParseDlDateTimeString(s :
string) : TDateTime;
var fs : TFormatSettings;
sl : TStringList;
i : integer;
date, time :
string;
begin
//s := '[23/Apr/2004:20:08:33';
date := copy(s, 2, 11);
//ShowMessage(date);
time := copy(s, 14, 8);
//ShowMessage(time);
GetLocaleFormatSettings(GetUserDefaultLCID, fs);
with fs
do
begin
fs.ShortMonthNames[1] := '
Jan';
fs.ShortMonthNames[2] := '
Feb';
fs.ShortMonthNames[3] := '
Mar';
fs.ShortMonthNames[4] := '
Apr';
fs.ShortMonthNames[5] := '
May';
fs.ShortMonthNames[6] := '
Jun';
fs.ShortMonthNames[7] := '
Jul';
fs.ShortMonthNames[8] := '
Aug';
fs.ShortMonthNames[9] := '
Sep';
fs.ShortMonthNames[10] := '
Oct';
fs.ShortMonthNames[11] := '
Nov';
fs.ShortMonthNames[12] := '
Dec';
sl := TStringList.Create;
sl.Delimiter := '
/';
sl.DelimitedText := date;
for i := 1
to 12
do
if ShortMonthNames[i] = sl[1]
then begin
if i < 10
then
sl[1] := '
0' + IntToStr(i)
else
sl[1] := IntToStr(i);
Break;
end;
date := Format('
%s/%s/%s', [sl[0], sl[1], sl[2]]);
sl.Free;
fs.DateSeparator := '
/';
fs.ShortDateFormat := '
dd/mm/yyyy';
fs.ShortTimeFormat := '
hh:mm:ss';
end;
result := StrToDate(date, fs) + StrToTime(time, fs);
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~