[tz] [PROPOSED PATCH 8/9] Add NetBSD-inspired functions for timezone_t objects.

lennox at cs.columbia.edu lennox at cs.columbia.edu
Tue Aug 26 09:59:24 UTC 2014


On Sunday, August 24 2014, "Paul Eggert" wrote to "tz at iana.org" saying:

> (tzalloc, tzfree) [NETBSD_INSPIRED]: New functions.

These functions aren't documented yet, as far as I can tell?

So I'm uncertain about their exact intended semantics.  But it seems there's
no way to get a timezone_t corresponding to the system wall clock time zone,
i.e. the one that would be used by the non _z versions of the functions?

If the TZ environment variable is set, tzalloc(getenv("TZ")) returns the
correct time zone, but if it isn't, you get GMT not localtime.  (I suppose
you could do readlink("/etc/localtime") in that case, but that's error-prone
and not very portable.)

Since NetBSD doesn't define what a NULL argument to tzalloc does, could I
suggest that it indeed mean /etc/localtime?  That way, tzalloc(getenv("TZ"))
always does the right thing.  (UTC can be obtained by passing "" to tzalloc,
just as you can for the TZ variable.)

I'd also suggest that tzalloc should fail for unknown time zone names,
rather than silently returning GMT.

This was the defined behavior of the similar proposal I made on (the
predecessor of) this list back in 2001:
<http://mm.icann.org/pipermail/tz/2001-June/011692.html>.  It might be worth
reading over some of the other discussion there as well.

-- 
Jonathan Lennox
lennox at cs.columbia.edu


More information about the tz mailing list