mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 18:10:17 +02:00
* Merging revisions 42800 from trunk:
------------------------------------------------------------------------ r42800 | michael | 2019-08-24 13:05:19 +0200 (Sat, 24 Aug 2019) | 1 line * Make order of ISO8601ToDate consistent, ReturnUTC always at the end, and default true ------------------------------------------------------------------------ git-svn-id: branches/fixes_3_2@42848 -
This commit is contained in:
parent
10629fb682
commit
a26b523a35
@ -453,9 +453,10 @@ Function TryISOTZStrToTZOffset(const TZ : String; Out TZOffset : Integer) : bool
|
|||||||
// ISO 8601 Date/Time formatting
|
// ISO 8601 Date/Time formatting
|
||||||
|
|
||||||
function DateToISO8601(const ADate: TDateTime; AInputIsUTC: Boolean = True): string;
|
function DateToISO8601(const ADate: TDateTime; AInputIsUTC: Boolean = True): string;
|
||||||
Function ISO8601ToDate(const DateString: string; ReturnUTC : Boolean): TDateTime;
|
Function ISO8601ToDate(const DateString: string; ReturnUTC : Boolean = True): TDateTime;
|
||||||
Function ISO8601ToDateDef(const DateString: string; ReturnUTC : Boolean; aDefault : TDateTime): TDateTime;
|
Function ISO8601ToDateDef(const DateString: string; ReturnUTC : Boolean; aDefault : TDateTime ): TDateTime; deprecated;
|
||||||
Function TryISO8601ToDate(const DateString: string; out ADateTime: TDateTime; ReturnUTC : Boolean) : Boolean;
|
Function ISO8601ToDateDef(const DateString: string; aDefault : TDateTime; ReturnUTC : Boolean = True ): TDateTime;
|
||||||
|
Function TryISO8601ToDate(const DateString: string; out ADateTime: TDateTime; ReturnUTC : Boolean = True) : Boolean;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -2896,7 +2897,7 @@ begin
|
|||||||
Raise EConvertError.CreateFmt('Invalid ISO timezone string',[TZ]);
|
Raise EConvertError.CreateFmt('Invalid ISO timezone string',[TZ]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TryISO8601ToDate(const DateString: string; out ADateTime: TDateTime;ReturnUTC : Boolean) : Boolean;
|
Function TryISO8601ToDate(const DateString: string; out ADateTime: TDateTime;ReturnUTC : Boolean = True) : Boolean;
|
||||||
|
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -2941,7 +2942,7 @@ begin
|
|||||||
Result:=True;
|
Result:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function ISO8601ToDate(const DateString: string; ReturnUTC : Boolean): TDateTime;
|
Function ISO8601ToDate(const DateString: string; ReturnUTC : Boolean = True): TDateTime;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if not TryISO8601ToDate(DateString,Result,ReturnUTC) then
|
if not TryISO8601ToDate(DateString,Result,ReturnUTC) then
|
||||||
@ -2955,6 +2956,14 @@ begin
|
|||||||
Result:=aDefault;
|
Result:=aDefault;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function ISO8601ToDateDef(const DateString: string; aDefault : TDateTime; ReturnUTC : Boolean = True): TDateTime;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if not TryISO8601ToDate(DateString,Result,ReturnUTC) then
|
||||||
|
Result:=aDefault;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$else}
|
{$else}
|
||||||
implementation
|
implementation
|
||||||
{$endif FPUNONE}
|
{$endif FPUNONE}
|
||||||
|
Loading…
Reference in New Issue
Block a user