On 20/10/2009, Michael Van Canneyt <mich...@freepascal.org> wrote:
>
>  The error is correct, since 05/05/1999 is not a valid date.
>  It should use - instead of / . I've adapted the example.


But couldn't you simply have forced DateSeparator to "-".

Also could we try not to have such an obscure example - using day and
month as the same value.! It would be much better and informative, if
the day value was greater than 12. Clearly distinguish between day and
month values.

eg:

Begin
  Writeln ('ShortDateFormat ',ShortDateFormat);
  TestStr(DateTimeToStr(Date));
  TestStr('16'+DateSeparator+'05'+DateSeparator+'1999');
  TestStr('16'+DateSeparator+'9');
  TestStr('16');
End.


Now you can clearly see when and where the day and month are
specified. If this causes issues on various locales, then maybe the
example could be hard-coded to the International ISO 8601 date format.

eg:

Begin
  ShortDateFormat = 'y-m-d';

{or maybe even better
  ShortDateFormat = 'y/m/d';
  DateSeparator = '-';
  TestStr(1999-05-16');

}


  Writeln ('ShortDateFormat ',ShortDateFormat);
  TestStr(DateTimeToStr(Date));
  TestStr('16'+DateSeparator+'05'+DateSeparator+'1999');
  TestStr('16'+DateSeparator+'9');
  TestStr('16');
End.



-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to