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

zeljko zeljko at holobit.net
Mon Oct 31 20:32:09 CET 2011


On Monday 31 of October 2011 20:17:46 you wrote:
> On Mon, 31 Oct 2011, zeljko wrote:
> > Hi,
> > 
> > 
> > I have daemon which uses Now() for getting current date/time, but
> > something is wrong, time on server changed from 03:00 to 02:00 this
> > weekend, but daemon's Now() was on old time ... until now ... I've just
> > restarted it and now it applied new time.
> > 
> > fpc-2.4.5, centos 5.5 ....
> > 
> > Also this confirms something what happens sometimes when ntpd changes
> > time ...
> > 
> > Any hints ? What to do ? Any workaround ?
> 
> It's probably the timezone information which is loaded only once at program
> startup.
> 
> This has been reported before, but no satisfying solution was found at the
> time. re-reading this file at each now() would be extremely slowing.

hm... dcc (kylix) uses localtime_r and this is from man page of that function.

The localtime() function converts the calendar time timep to broken-time 
representation, expressed relative to the user's  specified  time  zone.
       The function acts as if it called tzset(3) and sets the external 
variables tzname with information about the current time zone, timezone with 
the difference between Coordinated Universal Time (UTC) and local standard 
time in seconds, and daylight to a non-zero value if daylight savings time
   rules  apply  during  some  part  of the year.  The return value points to 
a statically allocated struct which might be overwritten by subsequent
     calls to any of the date and time functions.  The localtime_r() function 
does the same, but stores the data in a user-supplied struct.   It  need not 
set tzname.

What uses fpgettimeofday() ? 

zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20111031/a1485a40/attachment.html>


More information about the fpc-devel mailing list