Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-01

Is TryStrToDate works wrong?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Gabor Boros

Hi All,

var
   DT:TDateTime;
begin
   Writeln(BoolToStr(TryStrToDate('1',DT),True));

The result of above code is "True" with FPC and "False" with Delphi.

Gabor

Reply by email

Winfried Bartnick
to Michael Van Canneyt
Michael Van Canneyt wrote 23 lines
On Sat, 4 Jan 2020, Gabor Boros wrote: > Hi All, > > var >   DT:TDateTime; > > begin >   Writeln(BoolToStr(TryStrToDate('1',DT),True)); > > > The result of above code is "True" with FPC and "False" with Delphi. This is normal. FPC accepts more than Delphi, see the documentation: https://www.freepascal.org/docs-html/rtl/sysutils/strtodate.html Michael. _______________________________________________ fpc-pascal maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Hi!

The result is true, but the date is nonsense:

ShowMessage(BoolToStr(TryStrToDate('1',DT),True) + lineEnding +
formatdatetime('dd.mm.yyyy',DT));

results in

/True//
/

/01.01.2020/

Not what I exspected.

Winni

Reply by email

Michael Van Canneyt
to Winfried Bartnick
Winfried Bartnick wrote 16 lines
The result is true, but the date is nonsense: ShowMessage(BoolToStr(TryStrToDate('1',DT),True) + lineEnding + formatdatetime('dd.mm.yyyy',DT)); results in /True// / /01.01.2020/ Not what I exspected.

But exactly what it is supposed to return. It fills missing numbers with the current year/month. So, 1 jan 2020.

Michael.

Reply by email