(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
program timeparse;

{$APPTYPE CONSOLE}

uses
  SysUtils, DateUtils, Windows;

function MyStrToTime(aSt: string): TDateTime;

var
  hh,mm,ss,s100: word;

begin
  hh := StrToInt(copy(aSt,1,2));
  mm := StrToInt(copy(aSt,4,2));
  ss := StrToInt(copy(aSt,7,2));
  s100 := StrToInt(copy(aSt,10,3));
  result := EncodeTime(hh,mm,ss,s100);
end;

function MyStrToTime2(aSt: string): TDateTime;

begin
  result := StrToDateTime(aSt);
end;

function MyStrToTime3(aSt: string): TDateTime;

var
  tfs : TFormatSettings;
  
begin
  GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, tfs);
  tfs.TimeSeparator := ':';
  tfs.DecimalSeparator := ',';
  result := StrToDateTime(aSt, tfs);
end;

begin
  writeln(TimeToStr(MyStrToTime('12:14:16,123')));
  writeln(TimeToStr(MyStrToTime2('12:14:16,123')));
  writeln(TimeToStr(MyStrToTime3('12:14:16,123')));
end.
