Skip to content

Add overloaded function StrToTime(const S: string; const UseFormat: TFormatSettings): TDateTime;

Original Reporter info from Mantis: lacak @lacak.sk
  • Reporter name: LacaK

Description:

There is missing such functions, which will use FS.TimeSeparator and FS.DecimalSeparator to parse time strings with miliseconds.

http://docwiki.embarcadero.com/VCL/XE/en/SysUtils.StrToTime

Something like this (can be done smarter, but requires rearange existing functions):

function StrToTime(const S: string; const UseFormat: TFormatSettings): TDateTime;
var
  Msg : AnsiString;
begin
  Result:=IntStrToTime(Msg,@S[1],length(S),UseFormat);
  If (Msg<>'') then
    Raise EConvertError.Create(Msg);
end;

And then use this version of function in function StrToDateTime(const s: AnsiString; const UseFormat : TFormatSettings): TDateTime;

Because used version of StrToTime uses TimeSeparator from UseFormat, but DecimalSeparator from DefaultFormatSettings, which is not good!

Mantis conversion info:

  • Mantis ID: 19870
  • Version: 2.5.1
  • Fixed in version: 2.6.0
  • Fixed in revision: 18827 (#d2fcf6cd)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information