#1 2015-01-01 18:48:06

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Need DateTimeToIso8601 and Iso8601ToDateTime in Crossplatform ios, a..

Hi Ab i need this 2 Functions for iOS and Android. I just modified SynCrossPlatformSpecific.pas.

{$ifdef ISDWS}
{$if defined(IOS) or defined(ANDROID)}
function DateTimeToIso8601(Value: TDateTime): string;
function Iso8601ToDateTime(const Value: string): TDateTime;
{$ifend}

{$if defined(ISDWS)}
procedure DoubleQuoteStr(var text: string);
function IdemPropName(const PropName1,PropName2: string): boolean;
function StartWithPropName(const PropName1,PropName2: string): boolean;
@@ -330,14 +337,10 @@ procedure DecodeDate(Value: TDateTime; var Y,M,D: word);
function TryEncodeDate(Y,M,D: integer; var Value: TDateTime): boolean;
function TryEncodeTime(HH,MM,SS,MS: integer; var Value: TDateTIme): boolean;
function NowToIso8601: string;
function DateTimeToIso8601(Value: TDateTime): string;
function Iso8601ToDateTime(const Value: string): TDateTime;
function TryStrToInt(const S: string; var Value: integer): Boolean;
function TryStrToInt64(const S: string; var Value: Int64): Boolean;
function StrToInt64Def(const S: string; const def: Int64): Int64;
function UpCase(ch: Char): Char; inline;
function GetNextCSV(const str: string; var index: Integer; var res: string;
  Sep: char): boolean;

type
  /// which kind of document the TJSONVariantData contains
@@ -371,7 +374,7 @@ function ValueToJSON(Value: variant): string; external 'JSON.stringify';
// - match function signature as defined in SynCrossPlatformJSON
function JSONToValue(JSON: string): variant; external 'JSON.parse';

{$endif}
{$ifend}

...

  try
@@ -812,7 +820,9 @@ function NowToIso8601: string;
begin
  result := DateTimeToIso8601(Now);
end;
{$ifend}

{$if defined(ISDWS) or defined(IOS) or defined(ANDROID)}
function DateTimeToIso8601(Value: TDateTime): string;
begin // e.g. YYYY-MM-DD Thh:mm:ss or YYYY-MM-DDThh:mm:ss
  if Value<=0 then
@@ -858,8 +868,9 @@ begin //  YYYY-MM-DD   Thh:mm:ss  or  YYYY-MM-DDThh:mm:ss
  end;
  end;
end;
{$ifend}  // itSDS


{$if defined(ISDWS)}
{ TJSONVariantData }

{$HINTS OFF}
@@ -955,7 +966,7 @@ begin
  result := TSMSHttpConnectionClass;
end;

{$endif ISDWS}
{$ifend ISDWS}

Rad Studio 12.1 Santorini

Offline

#2 2015-01-01 18:52:29

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

Re: Need DateTimeToIso8601 and Iso8601ToDateTime in Crossplatform ios, a..

Your conditionals are buggy IMHO.
DWS is for SmartPascal.

Offline

#3 2015-01-02 13:25:47

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Need DateTimeToIso8601 and Iso8601ToDateTime in Crossplatform ios, a..

Hi Arnoud,

Happy New Year
seem's that i made an error by copy and Paste!

I moved the 2 needed functions aut of ISDWS and added

{$if defined(ISDWS) or defined(IOS) or defined(ANDROID)}

around it to have it on all 3 Platforms and not to modify too much of your code.

The reason: i want to use the ISO8601 Format to save "Registry" - DateTime Values on all Platforms.


Rad Studio 12.1 Santorini

Offline

Board footer

Powered by FluxBB