TryStrToDateTime always fail when DateSeparator is same as TimeSeparator
Original Reporter info from Mantis: Shebuka
-
Reporter name: Anton S.
Original Reporter info from Mantis: Shebuka
- Reporter name: Anton S.
Description:
if you use this string '2011-10-11 15-53' and set DateSeparator := '-' and TimeSeparator := '-' as FormatSettings, Pos will give you first occurrence of TimeSeparator inside string, wich is in date part!!! so after while cycle you get I := 0 and TryStrToTime fails because it expects only time string and not datetime. In this way whole logic is messed up.
Must fix also other Date function with same logic, like StrToDateTime.
Steps to reproduce:
str := '2011-10-11 15-53';
frmstg.DateSeparator := '-';
frmstg.ShortDateFormat := 'yyyy-mm-dd';
frmstg.TimeSeparator := '-';
frmstg.LongTimeFormat := 'hh-nn';
if not TryStrToDateTime(str, Result, frmstg) then
Result := Now();
Additional information:
Additional info here: http://www.lazarus.freepascal.org/index.php/topic,14928.msg80129.html#msg80129
Mantis conversion info:
- Mantis ID: 20522
- OS: OS X
- OS Build: 10.6.8
- Platform: Mac
- Version: 2.4.4
- Fixed in version: 3.0.0
- Fixed in revision: 27775 (#042e6243)
- Target version: 3.0.0