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

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Wed Nov 2 16:22:29 CET 2011



On Wed, 2 Nov 2011, zeljko wrote:

> On Wednesday 02 of November 2011 15:47:46 michael at freepascal.org wrote:
> Ok, let's finish this thread.
>
> 1.Now() works as it is - it's even twice faster now since extra fptime call is
> avoided (so an + from this  thread) :)
>
> 2.Programmer (me in this example) need something to re-read timezone, so Now()
> can adjust time - please merge your ReReadTimeZone() to 2.4.5 and 2.6.0.
> Also, documentation should be updated with this routine.
> If somebody needs accurate time in his timezone, let him call ReReadTimeZone()
> whenever. eg. I'll call it every day at some time after 03:00 so who cares ...
>

The call will not be merged. Instead, you can just add

  ReadTimezoneFile(GetTimezoneFile);
  GetLocalTimezone(fptime);

to your code (and add units 'unix' and 'baseunix'). 
This code does all that is needed, you need not even upgrade FPC for it
because these calls exist in 2.4, 2.6 and are documented.

> 3.Issue can be resolved in that case, Now() behaviour isn't changed, it's only
> faster.

You mean the bug tracker issue ?

> 4.If kernel clock_gettime() is really twice slower than gettimeodday, then use
> gettimeofday until it's completely removed from some future kernel, if not ,
> change it to use clock_gettime(CLOCK_REALTIME).

When we know that BSD and Darwin (and all other unix-like OSes) support this
call, yes, then we can do that.

Michael.



More information about the fpc-devel mailing list