[fpc-devel] Definition of the time-fration in a TDateTime before 30/12/1899

Joost van der Sluis joost at cnoc.nl
Sun May 21 15:45:17 CEST 2006


Hi all,

I have some questions about the TDateTime format.

I always thought that you could do this:
  TD : TDateTime

TD := EncodeDate()+encodeTime();

This would mean that you have the following: (24-hours notation)

 0     = 12/30/1899 00:00    (as defined)
 1     = 12/31/1899 00:00	
 1.25  = 12/31/1899 06:00 
-1     = 12/29/1899 00:00
-2     = 12/28/1899 00:00
-1.25  = 12/28/1899 18:00    (-2+0.75)

But now the Delphi help says:

-1.25  = 12/29/1899 06:00    

And this is how it's also implemented in FPC. But for instance
PostgreSQL which also uses a format like TDateTime does it the other
way. Which looks more logical to me, since if you want to know if
DateTimeA is after DateTimeB you can do: DateTimeA>DateTimeB

With the Delphi-help variant this won't work. Since -1>-1.25 but
12/29/1899 00:00 > 12/29/1899 06:00 doesn't make sence to me.

This implementation will mean that if you compare TDateTime's you first
have to check whether the date is before or after 12/30/1899 ?

There are some bugs in DecodeDate, DecodeTime and friends for dates
before 12/30/1899 but to fix those, I need to know what to do with this
problem.

Regards,
  Joost.




More information about the fpc-devel mailing list