[fpc-pascal] How to convert ISO format string in FreePascal
Frank Church
vfclists at googlemail.com
Tue Apr 27 17:43:30 CEST 2010
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. My
attempt is based on the method here,
https://forums.codegear.com/thread.jspa?threadID=16074, but
StrToDateTime in FPC does not use the FormatSettings parameter.
function // function TryStrToDate(const S: string; out Value:
TDateTime; const FormatSettings: TFormatSettings): Boolean;
// function TryStrToTime(const S: string; out Value: TDateTime; const
FormatSettings: TFormatSettings): Boolean;
// function TryStrToDateTime(const S: string; out Value: TDateTime;
const FormatSettings: TFormatSettings): Boolean;
(const S: string): TDateTime;
The references to FormatSettings are commented out, they appear to be
an abandoned attempt
// function TryStrToDate(const S: string; out Value: TDateTime; const
FormatSettings: TFormatSettings): Boolean;
// function TryStrToTime(const S: string; out Value: TDateTime; const
FormatSettings: TFormatSettings): Boolean;
// function TryStrToDateTime(const S: string; out Value: TDateTime;
const FormatSettings: TFormatSettings): Boolean;
function StrToDateTimeDef(const S: string; const Defvalue :
TDateTime): TDateTime;
I switched to using the unixtime value which is also present in the
records I am using, but it does not allow for Daylight Savings Time
and is currently an hour behind. Is there some way the FreePascal
libraries can adjust for DST? Is there some other unit I can use or
work through?
1272379859.203125 gives 2010-04-27 14:50:59 instead of 2010-04-27
15:50:59 in the UK.
My current code is based on "TDateTime(25569 + (StrToInt(epoch) *
1.0)/86400.0)".
--
Frank Church
=======================
http://devblog.brahmancreations.com
More information about the fpc-pascal
mailing list