[fpc-pascal] Regression in StrToDateTime()

LacaK lacak at zoznam.sk
Thu Jun 14 12:28:18 CEST 2018


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.




More information about the fpc-pascal mailing list