Subject: Re: libc timegm()
To: Luke Mewburn <lukem@NetBSD.org>
From: Klaus Klein <kleink@reziprozitaet.de>
List: netbsd-users
Date: 11/10/2003 19:26:29
On Monday 10 November 2003 01:30, Luke Mewburn wrote:

> On Sun, Nov 09, 2003 at 12:47:08PM -0800, Wolfgang  S. Rupprecht wrote:
>   | Is libc's timegm(3) depreciated?  It is missing from mktime(3) man
>   | page and I can't decide if it is on its way out or if this is a
>   | documentation oversight.
>   |
>   | timegm() cuts out a lot of nonsense when converting a UTC time in
>   | Y/M/D H:M:S to seconds_since_the_epoch so it would be a good thing to
>   | retain and document.
>
> I agree that timegm() is good functionality to retain, since there's no
> other easy way to convert a UTC struct tm (e.g, parsed with strptime(3))
> to a UTC time_t.
>
> On a related note, a function similar to tzset(3) that took a
> timezone argument rather than requiring the $TZ environment to be
> modified would allow mktime(3) to be used.

Actually, no; in a threaded environment it wouldn't make much sense to have 
a tzset-lookalike operating on global state.  This would merely shift that 
state from the environment to i.e. tzcode.

> I'm not sure if there's a standardized API for either of these features.

Some extensions have been proposed; I'm aware of those by Markus Kuhn[1] and 
Jonathan Lennox[2].


- Klaus

[1] http://www.cl.cam.ac.uk/~mgk25/time/c/
[2] <15137.1557.624282.591473@grandcentral.cs.columbia.edu> in the tz
    archives