pavkam / tzdb

Delphi/FPC Time Zone Database
https://www.iana.org/time-zones
BSD 3-Clause "New" or "Revised" License
84 stars 27 forks source link

FPC precision loss on TDateTime manipulation #17

Closed pavkam closed 5 years ago

pavkam commented 5 years ago

Invalid millisecond values in TDateTime manipulated in FPC. Might require some rounding.

pavkam commented 5 years ago

To make it clear - running the test suite on Delphi/DUnit - everything is green. Running the same tests under Linux/FPC results in about 12 failures. All of them related to the fact that millis. lose precision.

For example, one failure is related to the UTC offset between two dates: 3599 vs 3600 seconds. The issue is that the milliseconds are 3599.9999... So there is deep rounding error during calculation operations.

Not sure that we can prevent them though. I tried EncodeDateTime in FPC with the same values. And the resulting Date/Time delta is still erroneous.

pavkam commented 5 years ago

Fixed the tests. There is no conversion loss. But made sure to use Int64 in arithmetic.