[fpc-pascal] Some StrToTime questions

Bart bartjunk64 at gmail.com
Tue Jan 19 09:19:40 CET 2010


Since the current implementation of StrToTime is somewhat flawed (see:
http://bugs.freepascal.org/view.php?id=15505), I tried to improve it.
This, however left me with some questions about how to treat blanks in
the inputstring.

The current implementation treats blanks (#32) as if they were
TimeSeparators, which in effect makes it accept strings like "12 34
56" and treat it the same way as "12:34:56" (when (Time)Separator =
':').

In my (old) Delphi (3 Pro), TimeToStr does not accept #32 as separator
between the digits, not even when you do an explicite
SysUtils.Timeseparator := #32.
Newer versions of of Delphi, so I'm told, also accept milliseconds to
be specified, if preceeded by DecimalSeparator.

So my first question is how do recent Delphi's (D7 and up) handle the
follwong inputstrings:

Assuming TimeSeparator = ':' and DecimalSeparator = '.'

TimeToStr('12 34 56 am')
TimeToStr('12 34 56 789')
TimeToStr('12 34 56 .789')  //notice the decimalseparator

Set TimeSeparator = #32, DecimalSeparator = '.'

TimeToStr('12 34 56 am')  //the #32 before "am" is especially
interesting in this case
TimeToStr('12 34 56 789')
TimeToStr('12 34 56 .789')  //notice the decimalseparator

Set TimeSeparator = ':', DecimalSeparator = #32

TimeToStr('12 34 56 am')
TimeToStr('12 34 56 789')
TimeToStr('12 34 56 .789')  //notice the decimalseparator

Set TimeSeparator = #32, DecimalSeparator = #32

TimeToStr('12 34 56 am')  //the #32 before "am" is especially
interesting in this case
TimeToStr('12 34 56 789')
TimeToStr('12 34 56 .789')  //notice the decimalseparator

Delphi 3 rejects all give strings in all cases.

I'd be obliged if someone can test with recent Delphi version.


My second question is:
- If recent delphi's also reject #32 as seperator between digits,
should we implement fpc's TimeToStr to behave like Delphi, or do we
want to maintain "backwards compatibility", so that older programs
which rely on this feature will still be able to function?


Bart



More information about the fpc-pascal mailing list