[fpc-pascal] Why has StrToDate() failing under FPC 2.3.1 (64bit)

Graeme Geldenhuys graemeg.lists at gmail.com
Tue Oct 20 12:33:00 CEST 2009


On 20/10/2009, Michael Van Canneyt <michael at freepascal.org> wrote:
> -----------------------------------------------------------------
>  Call StrToDate to parse a string that specifies a date. If S does

[...]


>  First lines say it all. "dd/mm/yyy hh:nn" is not supposed to work.

That's up for discussion! :-) It says the string must specify a date.
It does not say it must ONLY specify a date. It parses the string from
the left extracting what it needs, once it has all required
information to build a date, it ignores the rest.

Also, do I specify a date from the 17th century? Does StrToDate()
limit itself forever to only assume 19xx & 20xxx dates?

Why does StrToDate() use the ShortDateFormat - didn't we learn our
lesson with the Y2K bug?


PS:
Oh and a nice hidden little features (I couldn't find documentation
for). When you specify a date format as 'yyyy/mm/dd' or dd/mm/yy
etc... The '/' character is NOT the separator! The '/' in that
formatting string means the separator specified by the global
DateSeparator variable.

Yet if you specify 'yyyy-mm-dd', then the '-' character IS the date
separator to use, ignoring global DateSeparator variable.

Maybe the FPC docs could be extended to include this little gem. By
the way, I tested the above theory with Kylix 3 and Delphi 7.

-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list