Recent

Author Topic: Cocoa database datetime problem  (Read 1697 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 1886
    • Lazarus and Free Pascal italian community
Cocoa database datetime problem
« on: February 07, 2019, 05:11:07 pm »
Hi guys, trying to migrate my projects to lazarus 2.1 with fpc 3.3.1 I have a problem in cocoa development. I work with firebird 2.5 on mac and when I run a query that returns datetime fields their value is always read as 00/00/0000, but if I run the same query from flamerobin the dates are evaluated. It is as if all the dates in the dataset were not read correctly. Use Zeos components 7.2 stable. Only I do not understand if the problem is of zeos or is of lazarus. Does anyone know how to solve?
Here the link to the 3d on zeos portal: http://zeoslib.sourceforge.net/viewtopic.php?f=40&t=87321
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 1886
    • Lazarus and Free Pascal italian community
Re: Cocoa database datetime problem
« Reply #1 on: February 07, 2019, 10:23:10 pm »
Now into discussion url: http://zeoslib.sourceforge.net/viewtopic.php?f=40&t=87321

I posted one example with firebird database backup to reproduce problem (with image of problem).
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 1886
    • Lazarus and Free Pascal italian community
Re: Cocoa database datetime problem
« Reply #2 on: February 09, 2019, 07:31:47 pm »
I found the problem but I do not know how to solve it. The DateTimeToNative function exists in the ZDatasetUtils file.

Which has the following line

TDateTime (Buffer ^): = TimeStampToMSecs (TimeStamp);

If I put the following code
var
app2: comp;
...
   app2: = TimeStampToMSecs (TimeStamp);
   writeln (FloatToStr (app2));

I get the following values on windows

07/02/2019 21:42:20
floattostr: 63685258940708

and on the following macs
07/02/2019 22:14:33
floattostr: -9.22337203685478E18

I know that the two dates are different, but the fact that the value on the mac is negative leads me to think that there is a problem. Ideas on how to solve it?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1