* strtodatetime adapted to new strtotime regime. Take separator from formatsettings.

Second patch fo Mantis #19870

git-svn-id: trunk@18100 -
This commit is contained in:
marco 2011-08-05 13:37:16 +00:00
parent aeb7dac66e
commit bf65638891
2 changed files with 16 additions and 16 deletions

View File

@ -712,14 +712,14 @@ function StrToTime(const S: PChar; Len : integer; FormatSettings : TFormatSettin
Var Var
Msg : AnsiString; Msg : AnsiString;
begin begin
Result:=IntStrToTime(Msg,S,Len,FormatSettings,Separator); Result:=IntStrToTime(Msg,S,Len,FormatSettings,#0);
If (Msg<>'') then If (Msg<>'') then
Raise EConvertError.Create(Msg); Raise EConvertError.Create(Msg);
end; end;
function StrToTime(const S: string; FormatSettings : TFormatSettings): TDateTime; function StrToTime(const S: string; FormatSettings : TFormatSettings): TDateTime;
begin begin
Result := StrToTime(@S[1], length(S), FormatSettings, #0); Result := StrToTime(@S[1], length(S), FormatSettings);
end; end;
function StrToTime(const s: ShortString; separator : char): TDateTime; function StrToTime(const s: ShortString; separator : char): TDateTime;
@ -764,42 +764,42 @@ begin
Result:=StrToDate(S); Result:=StrToDate(S);
end; end;
function StrToDateTime(const s: AnsiString; const UseFormat : TFormatSettings): TDateTime; function StrToDateTime(const s: AnsiString; const FormatSettings : TFormatSettings): TDateTime;
var var
I: integer; I: integer;
begin begin
I:=Pos(UseFormat.TimeSeparator,S); I:=Pos(FormatSettings.TimeSeparator,S);
If (I>0) then If (I>0) then
begin begin
While (I>0) and (S[I]<>' ') do While (I>0) and (S[I]<>' ') do
Dec(I); Dec(I);
If I>0 then If I>0 then
result:=ComposeDateTime(StrToDate(Copy(S,1,I-1),UseFormat.ShortDateFormat,UseFormat.DateSeparator), result:=ComposeDateTime(StrToDate(Copy(S,1,I-1),FormatSettings.ShortDateFormat,FormatSettings.DateSeparator),
StrToTime(Copy(S,i+1, Length(S)-i),UseFormat.TimeSeparator)) StrToTime(Copy(S,i+1, Length(S)-i),FormatSettings))
else else
result:=StrToTime(S,UseFormat.TimeSeparator) result:=StrToTime(S,FormatSettings)
end end
else else
Result:=StrToDate(S,UseFormat.ShortDateFormat,UseFormat.DateSeparator); Result:=StrToDate(S,FormatSettings.ShortDateFormat,FormatSettings.DateSeparator);
end; end;
function StrToDateTime(const s: ShortString; const UseFormat : TFormatSettings): TDateTime; function StrToDateTime(const s: ShortString; const FormatSettings : TFormatSettings): TDateTime;
var var
I: integer; I: integer;
begin begin
I:=Pos(UseFormat.TimeSeparator,S); I:=Pos(FormatSettings.TimeSeparator,S);
If (I>0) then If (I>0) then
begin begin
While (I>0) and (S[I]<>' ') do While (I>0) and (S[I]<>' ') do
Dec(I); Dec(I);
If I>0 then If I>0 then
result:=ComposeDateTime(StrToDate(Copy(S,1,I-1),UseFormat.ShortDateFormat,UseFormat.DateSeparator), result:=ComposeDateTime(StrToDate(Copy(S,1,I-1),FormatSettings.ShortDateFormat,FormatSettings.DateSeparator),
StrToTime(Copy(S,i+1, Length(S)-i),UseFormat.TimeSeparator)) StrToTime(Copy(S,i+1, Length(S)-i),FormatSettings.TimeSeparator))
else else
result:=StrToTime(S,UseFormat.TimeSeparator) result:=StrToTime(S,FormatSettings.TimeSeparator)
end end
else else
Result:=StrToDate(S,UseFormat.ShortDateFormat,UseFormat.DateSeparator); Result:=StrToDate(S,FormatSettings.ShortDateFormat,FormatSettings.DateSeparator);
end; end;
{ FormatDateTime formats DateTime to the given format string FormatStr } { FormatDateTime formats DateTime to the given format string FormatStr }

View File

@ -142,8 +142,8 @@ function StrToDate(const S: AnsiString; const useformat : string; separator : ch
function StrToTime(const S: PChar; Len : integer; separator : char = #0): TDateTime; function StrToTime(const S: PChar; Len : integer; separator : char = #0): TDateTime;
function StrToDate(const S: PChar; Len : integer; const useformat : string; separator : char = #0): TDateTime; function StrToDate(const S: PChar; Len : integer; const useformat : string; separator : char = #0): TDateTime;
function StrToDateTime(const S: string): TDateTime; function StrToDateTime(const S: string): TDateTime;
function StrToDateTime(const s: ShortString; const UseFormat : TFormatSettings): TDateTime; function StrToDateTime(const s: ShortString; const Formatsettings : TFormatSettings): TDateTime;
function StrToDateTime(const s: AnsiString; const UseFormat : TFormatSettings): TDateTime; function StrToDateTime(const s: AnsiString; const Formatsettings : TFormatSettings): TDateTime;
function FormatDateTime(const FormatStr: string; DateTime: TDateTime):string; function FormatDateTime(const FormatStr: string; DateTime: TDateTime):string;
function FormatDateTime(const FormatStr: string; DateTime: TDateTime; const FormatSettings: TFormatSettings): string; function FormatDateTime(const FormatStr: string; DateTime: TDateTime; const FormatSettings: TFormatSettings): string;
procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime); procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime);