[fpc-devel] Problem with Now() and time changed by ntpd

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Nov 3 03:12:27 CET 2011


Sven Barth schrieb:

> The solution mentioned above is a workaround for 2.4 where no fix is in 
> place. Newer versions of FPC (maybe even 2.6, I don't know about that) 
> will get an improved/fixed version of Now (how exactly seems to still be 
> debated).

ACK

> Also note that on platforms like Windows this would be a 
> unnecessary call as there the current(!) timezone bias is located in a 
> shared memory area which is mapped into each process by the kernel.

I don't think that this really is how Windows works. Delphi Now() 
retrieves an TSystemTime record (GetLocalTime), and converts its fields 
into an TDateTime value(EncodeDate/Time). A simple timezone bias is 
inapplicable to the TSystemTime data structure, but the kernel.dll may 
keep its conversion information somewhere in the DATA segment. On POSIX 
platforms gettimeofday and localtime_r is used instead (Delphi XE). All 
this handling makes Now() quite expensive, so that (a future) FPC should 
provide cheaper means for getting time stamps.

BTW, Windows itself provides GetSystemTime() based on *UTC*, and stored 
in TSystemTime. When monotonic timestamps are needed, even a Windows 
application can use this feature.

DoDi




More information about the fpc-devel mailing list