On Fri, Mar 25, 2016 at 9:23 AM, Bert Freudenberg <bert@freudenbergs.de> wrote:
On 25.03.2016, at 16:51, David T. Lewis <lewis@mail.msen.com> wrote:
>
> On Thu, Mar 24, 2016 at 10:05:17PM -0700, Eliot Miranda wrote:
>> I see two or three system calls in the code below.  gettimeofday, one inside localtime and one inside gmtime.  That's expensive.
>>
>
> It's gettimeofday() and localtime(). The #else is fallback for older unix platforms.
>
> In any case, caching the value and updating it periodically does not sound like a good idea to me.

Well, it’s okay to cheat as long as you won’t get caught (says DI).

Simply “once a second” is not good enough if we check the time 0.5 seconds after DST switch.

If “once a second” was implemented as “once every wall-clock second”, IMHO that would be fine. So the test would have to be something like

        (prevUsecs // 1000000) ~= (nowUsecs // 1000000) ifTrue: [self updateOffsetFromUTC]

Right?

Excellent point.  So the drift algorithm to provide an accurate clock can be extended to check the time zone whenever the new time is at a different second to the previous value.
 
- Bert -
 
_,,,^..^,,,_
best, Eliot