[fpc-pascal] Regression in StrToDateTime()

Carmel computer - Antal antal at carmelcomputer.com
Thu Jun 14 11:20:25 CEST 2018


You also can make your own procedure to fix the issue for yourself.
Like you can rewrite the function StrToDateTime() to change all '. ' to 
'.' and then call the original function StrToDateTime()


On Thu, 14 Jun 2018, LacaK wrote:

> Hi,
>
> now I am migrating my applications from FPC 2.6.4 to FPC 3.0.4 and I 
> noticed that logic in function StrToDateTime() was changed.
>
> In 2.6.4 there was first detected position of first TimeSeparator and 
> then walking back to first occurence of WhiteSpace.
> This approach allows DateSeparator='. ' (dot+space) which is for example 
> default settings in Windows7 in Slovak language (TimeSeparator=':').
>
> Now in FPC 3.0.4 firs occurence of space causes division of date and 
> time. It results in where:
> '11. 07. 2018 13:00' is divided to date part = '11.' and time part='07. 
> 2018' which is wrong.
>
> There is in FPC 3.0.4 new function SplitDateTimeStr():
> ...
>   //find separator
>   if (FS.DateSeparator<>#32) then
>     begin
>     while (p<Length(DateTimeStr)) and (not (DateTimeStr[p+1] in 
> WhiteSpace)) do
>       Inc(p);
>     end
>   else
>     begin
>     p:=Pos(FS.TimeSeparator, DateTimeStr);
>     if (p<>0) then
>       repeat
>         Dec(p);
>       until (p=0) or (DateTimeStr[p] in WhiteSpace);
>     end;
> ...
>
> In first part of code is located first occurnce of white space, which is 
> also part of DateSeparator!
> Can this be to fixed ?
>
> L.
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


More information about the fpc-pascal mailing list