[fpc-pascal] StrToDate bug?

Michael Van Canneyt michael at freepascal.org
Sat May 10 15:03:57 CEST 2014



On Sat, 10 May 2014, Bart wrote:

> Hi,
>
> I'm using fpc 2.6.4.
>
> While i was playing a bit with issue
> http://bugs.freepascal.org/view.php?id=20522 I stmbled upon unexpected
> behaviour of StrToDate function.
>
> StrToDate('6-12-2011 ') (note the space at the end) actually gives me 6-12-2014.

That is because the last part is not 'correct' (contains trailing garbage) and 
then the strtodate assumes the year is missing, and substitutes the current year,
as if you had specified 6-12.

It still functions like this in trunk.

A simple trim() will solve this, presumably.

Michael.



More information about the fpc-pascal mailing list