[fpc-devel] DB Bug in 2.0.1?

Michalis Kamburelis michalis at camelot.homedns.org
Thu Jul 21 05:56:48 CEST 2005


Tony Maro wrote:
> Jonas Maebe wrote:
> 
>>
>> On 21 jul 2005, at 00:40, Tony Maro wrote:
>>
>>> Can someone confirm the date issue for me?
>>
>>
>>
>> I can't confirm it, but I do want to mention that I fixed all  
>> datetime-related routines for *nix platforms in sysutils a while ago.  
>> They operated based on the supposition that the dates they get are in  
>> Windows format, as opposed to the number of seconds since x/x/1970.
> 
> 
> I have a concern on that - and please keep in mind I've not even looked 
> at the code, so I don't know if it's an issue or not.
> 
> My main purpose in using FPC is to write cross-platform applications.  
>  From what I gather, I'll now need to understand that TDateTime doesn't 
> actually store things the same way on different OS's?  I know, FPC's 
> goal is not specifically Delphi compatibility, but...
> 
> Here's a quote I found online:
> "In Delphi for Win32 (and Kylix), TDateTime is defined as a Double 
> (64-bit floating-point number). Date and time information is stored as 
> the count of days since midnight on 30-Dec-1899."
> 
> Here you can see that even Kylix uses the same methodology in storing 
> TDateTime values.
> 
> I can see both perspectives, but if the idea is to make it easier to 
> develop cross-platform software, I'd expect TDateTime to be stored the 
> same way across platforms regardless of how the OS counts.  A lot of 
> software written for Delphi is going to be awfully hard to convert for 
> Linux, Mac, etc if TDateTime is stored differently everywhere.
> 

AFAIK TDateTime internal format is the same for all platforms, and 
compatible to Delphi. I guess that Jonas meant his change at revision 
444, see
   svn diff -r 443:444
These fixes concern DateTimeToFileDate and FileDateToDateTime. The 
FileDate meaning is OS-dependent (and Jonas fixed DateTimeToFileDate and 
FileDateToDateTime to work accordingly).

(It's worth mentioning that good code shouldn't rely on internal 
TDateTime format anyway. Usually TDateTime should be treated as opaque 
type, and operated only using standard routines, like the ones from 
DateUtils unit.)

Michalis




More information about the fpc-devel mailing list