diff --git a/rtl/objpas/sysutils/dati.inc b/rtl/objpas/sysutils/dati.inc index bbf91f2368..1c0afa2931 100644 --- a/rtl/objpas/sysutils/dati.inc +++ b/rtl/objpas/sysutils/dati.inc @@ -768,7 +768,7 @@ begin end; {$endif unix} - +// ieuw. These should be written to work without exceptions? function TryStrToDate(const S: string; out Value: TDateTime): Boolean; begin result:=true; @@ -814,3 +814,21 @@ function TryStrToDateTime(const S: string; out Value: TDateTime): Boolean; // function TryStrToDateTime(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean; +function StrToDateDef(const S: string; const Defvalue : TDateTime): TDateTime; +begin + if not TryStrToDate(s,Result) Then + result:=defvalue; +end; + +function StrToTimeDef(const S: string; const Defvalue : TDateTime): TDateTime; +begin + if not TryStrToTime(s,Result) Then + result:=defvalue; +end; + +function StrToDateTimeDef(const S: string; const Defvalue : TDateTime): TDateTime; +begin + if not TryStrToDateTime(s,Result) Then + result:=defvalue; +end; + diff --git a/rtl/objpas/sysutils/datih.inc b/rtl/objpas/sysutils/datih.inc index ba926fc2f8..e55e7266d6 100644 --- a/rtl/objpas/sysutils/datih.inc +++ b/rtl/objpas/sysutils/datih.inc @@ -124,11 +124,17 @@ procedure DateTimeToString(out Result: string; const FormatStr: string; const Da Function DateTimeToFileDate(DateTime : TDateTime) : Longint; Function FileDateToDateTime (Filedate : Longint) :TDateTime; function TryStrToDate(const S: string; out Value: TDateTime): Boolean; -// function TryStrToDate(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean; function TryStrToTime(const S: string; out Value: TDateTime): Boolean; -// function TryStrToTime(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean; function TryStrToDateTime(const S: string; out Value: TDateTime): Boolean; + +// 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 StrToDateDef(const S: string; const Defvalue : TDateTime): TDateTime; +function StrToTimeDef(const S: string; const Defvalue : TDateTime): TDateTime; +function StrToDateTimeDef(const S: string; const Defvalue : TDateTime): TDateTime; + function CurrentYear:Word; { FPC Extra } Procedure GetLocalTime(var SystemTime: TSystemTime); diff --git a/rtl/objpas/sysutils/sysstr.inc b/rtl/objpas/sysutils/sysstr.inc index d48cc9d439..d4838b973e 100644 --- a/rtl/objpas/sysutils/sysstr.inc +++ b/rtl/objpas/sysutils/sysstr.inc @@ -1336,6 +1336,17 @@ begin Result:=FloatToStrF(Value,ffNumber,15,2); end; +function AnsiDequotedStr(const S: string; AQuote: Char): string; + +var p : pchar; + +begin + p:=pchar(s); // work around CONST + result:=AnsiExtractquotedStr(p,AQuote); + if result='' Then + result:=s; +end; + function StrToCurr(const S: string): Currency; begin if not TextToFloat(PChar(S), Result, fvCurrency) then diff --git a/rtl/objpas/sysutils/sysstrh.inc b/rtl/objpas/sysutils/sysstrh.inc index ec1e3a4a8e..60be81fda2 100644 --- a/rtl/objpas/sysutils/sysstrh.inc +++ b/rtl/objpas/sysutils/sysstrh.inc @@ -94,6 +94,7 @@ function TrimLeft(const S: string): string; function TrimRight(const S: string): string; function QuotedStr(const S: string): string; function AnsiQuotedStr(const S: string; Quote: char): string; +function AnsiDequotedStr(const S: string; AQuote: Char): string; function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string; function AdjustLineBreaks(const S: string): string; function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle): string;