C/C++ library that parses TZ data?

Isaac Hogue isaac.hogue at iformata.com
Wed Feb 9 16:38:24 UTC 2011


We utilize the C# library, http://zoneinfo.codeplex.com/Thread/View.aspx?ThreadId=50756

This Loads the library into the application's cache as a global static variable and gives you direct access to zone conversions using the utc time and a zone name.

There are other solutions similar to this avaialble; but, I'm not sure from a C or C++ perspective.

Hope this helps


Iformata Communications LLC
130 West Second St, Suite 1111,
Dayton, Ohio 45402
Main: +1-937-832-6900
Direct: +1-937-832-6961

Please consider the environment before printing.

This communication (including any attachments) may contain privileged or confidential information of Iformata LLC and is intended for a specific individual.  If you are not the intended recipient, you should delete this communication, including any attachments without reading or saving them in any manner, and you are hereby notified that any disclosure, copying, or distribution of this communication, or the taking of any action based on it, is strictly prohibited; if you received this in error please notify me immediately by replying to this message stating you received it in error.

On Feb 9, 2011, at 11:23 AM, Olson, Arthur David (NIH/NCI) [E] wrote:

I'm forwarding this message from Dario Teixeira, who is not on the time zone mailing list. Those of you who are on the list, please direct replies appropriately.


-----Original Message-----
From: Dario Teixeira [mailto:darioteixeira at yahoo.com]
Sent: Wednesday, February 09, 2011 11:03
To: tz at lecserver.nci.nih.gov<mailto:tz at lecserver.nci.nih.gov>
Subject: C/C++ library that parses TZ data?


I have a problem which is fairly common when one is running a web application
that wishes to display timestamps localised towards each user's time zone.
Basically, I need a function that takes as input a timestamp in UTC and
a time zone specified in the Zoneinfo convention (ex: "Europe/Lisbon"),
and returns the localised version of that timestamp, including a time zone
abbreviation aware of daylight savings.  Example:

2010-01-01 15:30, "Europe/Lisbon"       -> 2010-01-01 15:30 WET
2010-01-01 15:30, "Europe/Paris"        -> 2010-01-01 16:30 CET

2010-07-01 15:30, "Europe/Lisbon"       -> 2010-07-01 16:30 WEST
2010-07-01 15:30, "Europe/Paris"        -> 2010-07-01 17:30 CEST

Since the zoneinfo data is present in every Unix system and glibc includes
routines for parsing it, interfacing with glibc seemed the obvious solution.
Unfortunately, glibc was not designed with this use case in mind.  In fact,
the glibc interface to zoneinfo can be described as "sui generis" if one
is feeling charitable, or "insane" if truth must be told.  Specifically, to
obtain the localised version of a given timestamp, one must first set the 'TZ'
environment variable with the target timezone, and then invoke 'localtime'.
The abbreviated name of the timezone can be found in the global 'tzname'
array: at position 'tzname[0]' if daylight savings are not in effect and at
position 'tzname[1]' if they are.  A quick search through glibc's bugzilla
shows I'm not the only one to find this interface anachronistic [1], but it
also reveals that it is unlikely to change.

So, my question is if someone is aware of some alternative library in C
or C++ that provides this same functionality, but is friendlier towards
concurrent applications.

Best regards,
Dario Teixeira

[1] http://sources.redhat.com/bugzilla/show_bug.cgi?id=11620

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20110209/50dda5f8/attachment.htm>

More information about the tz mailing list