Mike Crowe
Mike Crowe

Reputation: 2294

Convert Olson time zone file to TZ environment variables

We are using the "America/New_York" convention for the user to select the timezone, but in our resource constrained system, we must manually provide the actual TZ variable. For example, for New York, we have:

timezones["America/New_York"] = "EST5EDT,M3.2.0,M11.1.0";

However, the resource we found to provide these environment settings only had a subset of all the US regions, and I'm trying to construct the remaining ones. For example, I need to build America/Kentucky/Louisville and America/Boise.

Is there resource with this built, or an existing script which can convert the Olson conventions to TZ environment variables? I've googled for a while, and can't find anything (and am nervous about implementing the logic myself).

TIA Mike

Upvotes: 2

Views: 795

Answers (1)

caf
caf

Reputation: 239251

The descriptions of each timezone are usually stored in files under /usr/share/zoneinfo (eg. /usr/share/zoneinfo/America/Kentucky/Louisville). The tzfile(5) man page describes the structure of these files.

Note that the files contain different rules to be used depending on the date, to account for past and future political changes to the time rules for each time zone (so you can't just say "give me the string for America/Kentucky/Louisville", you have to say "give me the string for America/Kentucky/Louisville, valid as at 2-September-2010").

Upvotes: 1

Related Questions