[fpc-pascal] How to convert ISO format string in FreePascal

Luiz Americo Pereira Camara luizmed at oi.com.br
Tue Apr 27 20:53:53 CEST 2010


Frank Church escreveu:
> I want to convert a time stamp in yyyy-mm-dd hh:mm:ss format to a
> TDatetime in FPC but can't find but haven't found a way yet.

 A very simple function i use:

function XMLDateTime2DateTime(const XMLDateTime: String): TDateTime;
var
  DateOnly: String;
  TPos: Integer;
begin
  TPos := Pos('T', XMLDateTime);
  if TPos <> 0 then
    DateOnly := Copy(XMLDateTime, 1, TPos - 1)
  else
    DateOnly := XMLDateTime;
  Result := ScanDateTime('yyyy-mm-dd', DateOnly);
end;


Luiz



More information about the fpc-pascal mailing list