Re: bug in time() related to DST?

From: Alexander Grigoriev (alegr_at_earthlink.net)
Date: 06/17/04


Date: Thu, 17 Jun 2004 15:30:23 -0700

In MSVC 7, time() function is implemented with GetSystemTimeAsFileTime,
which supposedly should be more reliable. But I'm not sure if it completely
closes that short window of DST transition. If you want ANSI C function for
measuring intervals, use clock(). It won't suffer from any effects of DST
switch, even from transition.

"Mike Johnston" <MikeJohnston@discussions.microsoft.com> wrote in message
news:B027C4BB-0256-4867-88D2-7333AAC6C70F@microsoft.com...
> Hi,
>
> On the morning of April 4, several of the services we have running had an
error
> in comparing values of the time() function. Whne comparing the current
value of
> time() with a previous value (some few seconds ago) the difference was
> a large number. The code is looking for timeouts in field devices.
>
> I think there is a bug in time() and I would like either a confirmation or
> an indication of what the bug in my code is. If there is a bug, is there a
recommended workaround?
>
> The servers are running Win2000 Server. They have dual Xenon processors.
>
> The services generate logs that are timestamped to the ms with
GetLocalTime().
>
> I observed that the actual transition to Daylight Saving time occured at
about 600ms after the hour. I think this is crucial to the problem.
>
> In the time() function, the following calls are made.
> GetLocalTime( &loct );
> GetSystemTime( &gmt );
> GetTimeZoneInformation( &tzinfo );
>
> If the OS decides to switch to DST in between the first and third function
> call, the time data will be inconsistent.
>
> I have a second theory that is not defensible because I don't know
> the actual values. This seems plausible because this happened to all
> the services running on the server.
>
>
> In the time() function the information from GetTimeZoneInformation() is
cached. It is only refreshed 1 time per minute at the fastest rate.
>
> If a call to time() is made at 2:00:00.100 the TZ info will be standard
time.
> The call to GetLocalTime() will have the correct time and the time()
function
> will return the correct time.
>
> If a subsequent call to time() is made at 3:00:01.000 is made, the cached
TZ information will be incorrect and the return value from time() will be
off by 1 hour.
>
>
>
> Is this the correct interpretation of the time() function?
>
> Thanks
>
> --
> Mike Johnston



Relevant Pages

  • Re: [patch] e1000=y && e1000e=m regression fix
    ... well it was Auke who compared it to the libata transition not me ... ... I'd have preferred to have sent only my first report. ... My bug was i think ... driver guys are pulling off a show like that with a fellow kernel ...
    (Linux-Kernel)
  • Re: SBS2003 to standard with Transition Pack: Really that easy?
    ... These most definitely include UN-INSTALLING Veritas BackupExec. ... Disconnect the server from the internet completely. ... Just make sure you have the matching TP version to your SBS ... Finally, just run the transition. ...
    (microsoft.public.windows.server.sbs)
  • Re: Transition Pack question/problem
    ... Before you run the Transition Pack there are a few steps you should take to ensure a smooth transiition: ... Disconnect the server from the internet completely. ... (ie, SP1 for SP1 SBS, etc.) ... Im currently restoring a backup that i did before i started this, then got to reading about it, do I need to buy the $300 upgrade to SBS Server '03 R2 before i can even install this? ...
    (microsoft.public.windows.server.sbs)
  • Re: SBS Transition Pack
    ... My standard response on running the transition pack: ... Before you run the Transition Pack there are a few steps you should take to ... Disconnect the server from the internet completely. ... Just make sure you have the matching TP version to your SBS ...
    (microsoft.public.windows.server.sbs)
  • Re: licensing after running SBS 2003 transition pack
    ... we do have a terminal server in the domain. ... just ran the transition pack last weekend. ... we should have 25 CALs in total after transition. ... the license logging service was disabled right after completed the ...
    (microsoft.public.windows.server.sbs)