[tz] [PROPOSED PATCH 8/9] Add NetBSD-inspired functions for timezone_t objects.
Alan Barrett
apb at cequrux.com
Mon Aug 25 07:25:13 UTC 2014
Thank you for this.
I haven't yet compared the code with what's currently in NetBSD,
but I immediately noticed that there's no mention that a null
pointer may be passed instead of a timezone_t, and this is a shorthand
for UTC.
Here are some extract's from NetBSD's ctime(3) man page to illustrate
what I mean:
FUNCTIONS
[...]
ctime_rz(tz, clock, buf)
The ctime_rz() function is similar to ctime_r(), but it also takes
a const timezone_t argument, as returned by a previous call to
tzalloc(), or a null pointer denoting Coordinated Universal Time
(UTC).
localtime_rz(tz, clock, result)
The localtime_rz() function is similar to localtime_r(), but it
also takes a const timezone_t argument, returned by a previous call
to tzalloc(), or a null pointer denoting Coordinated Universal Time
(UTC).
mktime_z(tz, tm)
The mktime_z() function is similar to mktime() but it also takes a
const timezone_t argument, returned by a previous call to
tzalloc(), or a null pointer denoting Coordinated Universal Time
(UTC).
tzalloc(zone)
The tzalloc() function takes as an argument a timezone name and
returns a timezone_t object suitable to be used in the ctime_rz(),
localtime_rz(), and mktime_z() functions.
A null pointer may be passed to tzalloc() instead of a timezone
name, to refer to Coordinated Universal Time (UTC).
Note that instead of setting the environment variable TZ, and
globally changing the behavior of the calling program, one can use
multiple timezones at the same time by using separate timezone_t
objects allocated by tzalloc() and calling the ``z'' variants of
the functions.
RETURN VALUES
[...]
o The tzalloc() function returns a pointer to a timezone_t object or
NULL on failure, setting errno to indicate the error. It may also
return NULL when the name argument is NULL, and this is not an error,
but a way of referring to Coordinated Universal Time (UTC).
--apb (Alan Barrett)
More information about the tz
mailing list