Proposal: API for thread-safe time zone functions

Joseph S. Myers jsm28 at cam.ac.uk
Thu Jun 7 16:30:58 UTC 2001


On Thu, 7 Jun 2001, Jonathan Lennox wrote:

> I've drawn a lot of inspiration for this work from Ulrich Drepper's work on
> thread-aware POSIX locales (http://www.cygnus.com/~drepper/tllocale.ps.bz2).
>
> * Are people interested in this?
> * Do people think that my proposal is a sensible API?
> * Would people be interested in seeing the resulting code?
> * Would people be interested in helping write the code?
> * Would the resulting code (assuming it's written sensibly) be
>   acceptable/appropriate for incorporation into tzcode?
>
> Comments very welcome!

Have you looked at Markus Kuhn's proposal at

http://www.cl.cam.ac.uk/~mgk25/c-time/

and the other ones linked to from there?

My recommendations:

* Design the proposal as an amendment for ISO C rather than POSIX.
* Don't touch how timestamps are represented (any interface can be adapted
to use any time_t replacement that gets agreed).
* Provide a struct tm replacement with (a) subsecond resolution and (b) a
proper field indicating which repetition of a repeated timestamp is
referred to (A/B in German time notation), rather than the inadequate
indication of whether the time is in daylight savings.
* Provide four conversion functions: between time_t and broken down times,
in either direction, and equivalents of strftime and wcsftime.  Don't
duplicate other functions such as asctime that can easily be replicated.
* Use an C99 snprintf-style return value (return the length of buffer
required if the buffer isn't long enough) rather than what strftime
currently does (return 0 if the buffer isn't long enough).
* Provide specified timezone names for both the user's local timezone and
the system's local timezone.

-- 
Joseph S. Myers
jsm28 at cam.ac.uk




More information about the tz mailing list