Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-06

Re: Regression in StrToDateTime()

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Carmel computer - Antal
to LacaK: now I am migrating my applications from FPC 2.6.4 to FPC 3.0.4 and I noticed that logic…

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()

LacaK wrote 43 lines
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 (p0) 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 - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
LacaK

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 (p0) 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.

LacaK
to Carmel computer - Antal: You also can make your own procedure to fix the issue for yourself. Like you can rewrite…
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()

Of course it is possible, but IMO it should be fixed in general way. I have reported bug #33860
I can prepare think about patch, but I must know what situations, formats must be supported by SplitDateTimeStr() and what is expected output. (this should be documented is source code)
L.

Show quoted text 53 lines
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 (p0) 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  -  > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal