[ntp:questions] Re: Jonathan Buzzard's radioclkd and FreeBSD

Hans Jørgen Jakobsen hjj at wheel.dk
Sun Nov 9 21:45:05 UTC 2003


On Sun, 09 Nov 2003 20:14:15 GMT, Wolfgang S. Rupprecht wrote:
> 
> Hans Jørgen Jakobsen <hjj at wheel.dk> writes:
>>>       dectimet = timegm ( &dectime );
> 
> Thanks for posting this.  I hadn't realized that libc() had an
> undocumented utc version of mktime().  Up to this point I'd been using
> this following hack to fix up the offset.
> 
>     tm->tm_isdst = -1;
>     time = mktime(tm);
>     if (time >= 0) {
> 	time += tm->tm_gmtoff;
>     } 
> 
> Seeing how much work libc/time/localtime.c:mktime() does to generate
> the time with the offset, using timegm() is clearly superior.

Your have a point in that timegm is non std. A closer look at the FreeBSD
man page conformed that its non std. ANd as far as i can see its not present
in Solaris 8 (At least not in the man pages)

I have some trouble convincing myself that there ar no bugs lurking in the
code above. What happens when we are changing summertime/normaltime?? 

If timegm is not universal available the best thing could be to let
mktime do all the conversion including summertime.

/hjj



More information about the questions mailing list