mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 05:59:28 +02:00
* 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:
parent
aeb7dac66e
commit
bf65638891
@ -712,14 +712,14 @@ function StrToTime(const S: PChar; Len : integer; FormatSettings : TFormatSettin
|
||||
Var
|
||||
Msg : AnsiString;
|
||||
begin
|
||||
Result:=IntStrToTime(Msg,S,Len,FormatSettings,Separator);
|
||||
Result:=IntStrToTime(Msg,S,Len,FormatSettings,#0);
|
||||
If (Msg<>'') then
|
||||
Raise EConvertError.Create(Msg);
|
||||
end;
|
||||
|
||||
function StrToTime(const S: string; FormatSettings : TFormatSettings): TDateTime;
|
||||
begin
|
||||
Result := StrToTime(@S[1], length(S), FormatSettings, #0);
|
||||
Result := StrToTime(@S[1], length(S), FormatSettings);
|
||||
end;
|
||||
|
||||
function StrToTime(const s: ShortString; separator : char): TDateTime;
|
||||
@ -764,42 +764,42 @@ begin
|
||||
Result:=StrToDate(S);
|
||||
end;
|
||||
|
||||
function StrToDateTime(const s: AnsiString; const UseFormat : TFormatSettings): TDateTime;
|
||||
function StrToDateTime(const s: AnsiString; const FormatSettings : TFormatSettings): TDateTime;
|
||||
var
|
||||
I: integer;
|
||||
begin
|
||||
I:=Pos(UseFormat.TimeSeparator,S);
|
||||
I:=Pos(FormatSettings.TimeSeparator,S);
|
||||
If (I>0) then
|
||||
begin
|
||||
While (I>0) and (S[I]<>' ') do
|
||||
Dec(I);
|
||||
If I>0 then
|
||||
result:=ComposeDateTime(StrToDate(Copy(S,1,I-1),UseFormat.ShortDateFormat,UseFormat.DateSeparator),
|
||||
StrToTime(Copy(S,i+1, Length(S)-i),UseFormat.TimeSeparator))
|
||||
result:=ComposeDateTime(StrToDate(Copy(S,1,I-1),FormatSettings.ShortDateFormat,FormatSettings.DateSeparator),
|
||||
StrToTime(Copy(S,i+1, Length(S)-i),FormatSettings))
|
||||
else
|
||||
result:=StrToTime(S,UseFormat.TimeSeparator)
|
||||
result:=StrToTime(S,FormatSettings)
|
||||
end
|
||||
else
|
||||
Result:=StrToDate(S,UseFormat.ShortDateFormat,UseFormat.DateSeparator);
|
||||
Result:=StrToDate(S,FormatSettings.ShortDateFormat,FormatSettings.DateSeparator);
|
||||
end;
|
||||
|
||||
function StrToDateTime(const s: ShortString; const UseFormat : TFormatSettings): TDateTime;
|
||||
function StrToDateTime(const s: ShortString; const FormatSettings : TFormatSettings): TDateTime;
|
||||
var
|
||||
I: integer;
|
||||
begin
|
||||
I:=Pos(UseFormat.TimeSeparator,S);
|
||||
I:=Pos(FormatSettings.TimeSeparator,S);
|
||||
If (I>0) then
|
||||
begin
|
||||
While (I>0) and (S[I]<>' ') do
|
||||
Dec(I);
|
||||
If I>0 then
|
||||
result:=ComposeDateTime(StrToDate(Copy(S,1,I-1),UseFormat.ShortDateFormat,UseFormat.DateSeparator),
|
||||
StrToTime(Copy(S,i+1, Length(S)-i),UseFormat.TimeSeparator))
|
||||
result:=ComposeDateTime(StrToDate(Copy(S,1,I-1),FormatSettings.ShortDateFormat,FormatSettings.DateSeparator),
|
||||
StrToTime(Copy(S,i+1, Length(S)-i),FormatSettings.TimeSeparator))
|
||||
else
|
||||
result:=StrToTime(S,UseFormat.TimeSeparator)
|
||||
result:=StrToTime(S,FormatSettings.TimeSeparator)
|
||||
end
|
||||
else
|
||||
Result:=StrToDate(S,UseFormat.ShortDateFormat,UseFormat.DateSeparator);
|
||||
Result:=StrToDate(S,FormatSettings.ShortDateFormat,FormatSettings.DateSeparator);
|
||||
end;
|
||||
|
||||
{ FormatDateTime formats DateTime to the given format string FormatStr }
|
||||
|
@ -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 StrToDate(const S: PChar; Len : integer; const useformat : string; separator : char = #0): TDateTime;
|
||||
function StrToDateTime(const S: string): TDateTime;
|
||||
function StrToDateTime(const s: ShortString; const UseFormat : TFormatSettings): TDateTime;
|
||||
function StrToDateTime(const s: AnsiString; const UseFormat : TFormatSettings): TDateTime;
|
||||
function StrToDateTime(const s: ShortString; const Formatsettings : 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; const FormatSettings: TFormatSettings): string;
|
||||
procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime);
|
||||
|
Loading…
Reference in New Issue
Block a user