New APIs to allow conversion of times in arbitrary zones
Michael.Lindner at idt.net
Tue May 26 20:04:09 UTC 2009
If you're going to have such an interface, why not make it reentrant as well? That, IMHO, is the biggest shortcoming of the current set of standards.
From: Guy Harris [mailto:guy at alum.mit.edu]
Sent: Tue 5/26/2009 2:00 PM
To: tz at lecserver.nci.nih.gov
Subject: New APIs to allow conversion of times in arbitrary zones
For the benefit of programs such as world clocks and any other program
that would need to convert times in an arbitrary zone specified by a
TZ setting, I've added some APIs to load time zone information for a
specified zone, free that time zone information, and convert between
time_t and struct tm in specified zones:
zoneinfo_t loadzone(const char *zonename)
Attempts to allocate and fill in a structure to hold information for
the time zone specified by "zonename"; returns a pointer to the time
zone information on success and NULL on failure.
void freezone(zoneinfo_t zoneinfo)
Frees zone information returned by loadzone().
struct tm *localtime_zr(const time *clock, struct tm *result,
Like localtime_r(), but does the conversion in the time zone specified
time_t mktime_z(struct tm *timeptr)
Like mktime(), but does the conversion in the time zone specified by
zoneinfo_t is implemented, internally, as a pointer to a "struct
state", but it's opaque to the callers.
I'm not committed to any of the names, or the order of the arguments;
for example, "loadzone()" doesn't necessarily load information from a
file - it might parse a POSIX-style TZ string - so that might not be
the right name.
The new functions are declared in an "xtime.h" public header (the name
was inspired by the BSD "xlocale.h" header that declares functions
such as printf_l() which take a locale information pointer as an
See the attached patch and "xtime.h" file.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 3485 bytes
Desc: not available
Url : http://mm.icann.org/pipermail/tz/attachments/20090526/8f18d90a/attachment-0001.bin
More information about the tz