#1 2014-01-24 18:37:53

edismo
Member
From: Brazil
Registered: 2013-10-04
Posts: 34

New function Iso8601ToDateTime

Hi AB,

Today exists Iso8601ToDateTime only RawUTF8 to TDateTime.
It´s possible new function add in SynCommons to convert Int64 to TDateTime?

Sample:

function Iso8601ToDateTime(const Value: Int64): TDateTime; overload;
begin
  Result := PIso8601(@Value)^.ToDateTime;
end;

I need using with IncDay.

Sample:

  ReferenceDate := IncDay(Iso8601ToDateTime(MySQLRecord.CreatedAt), Days);

Offline

#2 2014-01-25 16:26:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,273
Website

Re: New function Iso8601ToDateTime

Why not just use Iso8601(Value).ToDateTime in your code?

Offline

#3 2014-01-27 11:44:22

edismo
Member
From: Brazil
Registered: 2013-10-04
Posts: 34

Re: New function Iso8601ToDateTime

In Delphi 6 "Internal error: URW699" when compiling.
But PIso8601 (@ ADataIso8601mORMot) ^. ToDateTime works.
Iso8601ToDateTime is simpler

Offline

#4 2014-01-28 13:52:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,273
Website

Re: New function Iso8601ToDateTime

We have renamed Iso8601 low-level structure as TTimeLogBits, and use explicitly the TTimeLog type and name for all Int64 bit-oriented functions - now *Iso8601* will be used only for standard ISO-8601 textual representation.
See http://synopse.info/fossil/info/e6c05e58a9

Then, we added a new TimeLogToDateTime() function, to fulfill your expectations.
You can now write:

aTimeStamp := TimeLogFromDateTime(IncDay(TimeLogToDateTime(aTimeStamp)));

Thanks for the feedback!

Offline

#5 2014-01-28 17:14:07

edismo
Member
From: Brazil
Registered: 2013-10-04
Posts: 34

Re: New function Iso8601ToDateTime

thanks AB

Offline

Board footer

Powered by FluxBB