Tz database


The tz database is a collaborative compilation of information about the world's time zones and rules for observing daylight saving time, primarily intended for use with computer programs and operating systems. Paul Eggert has been its editor and maintainer since 2005, with the organizational backing of ICANN. The tz database is also known as tzdata, the zoneinfo database or the IANA time zone database, and occasionally as the Olson database, referring to the founding contributor, Arthur David Olson.
Its uniform naming convention for entries in the database, such as America/New_York and Europe/Paris, was designed by Paul Eggert. The database attempts to record historical time zones and all civil changes since 1970, the Unix time epoch. It also records leap seconds.
The database, as well as some reference source code, is in the public domain. New editions of the database and code are published as changes warrant, usually several times per year.

Data structure

Definition of a timezone

Within the tz database, a timezone is any national region where local clocks have all agreed since 1970. This definition concerns itself first with geographic areas which have had consistent local clocks. A timezone is different from a region with a particular standard time offset from UTC, which is often referred to as a "time zone". Therefore, each of the timezones defined by the tz database may use multiple offsets from UTC, such as offsets for standard time and daylight saving time.

File formats

The tz database is published as a set of text files which list the rules and zone transitions in a human-readable format. For use, these text files are compiled into a set of platform-independent binary files—one per timezone. The reference source code includes such a compiler called zic, as well as code to read those files and use them in standard APIs such as localtime and mktime.

Timezones

Each timezone has one or more "zone lines" in one of the tz database text files. The first zone line for a timezone gives the name of the timezone; any subsequent zone lines for that timezone leave the name blank, indicating that they apply to the same zone as the previous line. Each zone line for a zone specifies, for a range of date and time, the offset to UTC for standard time, the name of the set of rules that govern daylight saving time, the format for time zone abbreviations, and, for all but the last zone line, the date and time at which the range of date and time governed by that line ends.

Daylight saving time (DST) rules

The rules for daylight saving time are specified in named rule sets. Each rule set has one or more rule lines in the text files. A rule line contains the name of the rule set to which it belongs, the first year in which the rule applies, the last year in which the rule applies, the type of year to which the rule applies, the month in which the rule takes effect, the day on which the rule takes effect, the time of day at which the rule takes effect, the amount of time to add to the offset to UTC when the rule is in effect, and the letter or letters to use in the time zone abbreviation.

Names of timezones

The timezones have unique names in the form "Area/''Location", e.g. "America/New_York". A choice was also made to use English names or equivalents, and to omit punctuation and common suffixes. The underscore character is used in place of spaces. Hyphens are used where they appear in the name of a location. The Area and Location'' names each have a maximum length of 14 characters.

Area

Area is the name of a continent, an ocean, or "Etc". The continents and oceans used are Africa, America, Antarctica, Arctic, Asia, Atlantic, Australia, Europe, Indian, and Pacific.
The oceans are included since some islands are hard to connect to a certain continent. Some are geographically connected to one continent and politically to another. See also Boundaries between continents.
The special area of "Etc" is used for some administrative zones, particularly for "Etc/UTC" which represents Coordinated Universal Time. In order to conform with the POSIX style, those zone names beginning with "Etc/GMT" have their sign reversed from the standard ISO 8601 convention. In the "Etc" area, zones west of GMT have a positive sign and those east have a negative sign in their name.

Location

Location is the name of a specific location within the area – usually a city or small island.
Country names are not normally used in this scheme, primarily because they would not be robust, owing to frequent political and boundary changes. The names of large cities tend to be more permanent. Usually the most populous city in a region is chosen to represent the entire timezone, although another city may be selected if it is more widely known, and another location, including a location other than a city, may be used if it results in a less ambiguous name. In the event that the name of the location used to represent the timezone changes, the convention is to create an alias in future editions so that both the old and new names refer to the same database entry.
In some cases the Location is itself represented as a compound name, for example the timezone "America/Indiana/Indianapolis". Three-level names include those under "America/Argentina/...", "America/Kentucky/...", "America/Indiana/...", and "America/North_Dakota/...".
The location selected is representative of the entire area; that is, the current time at the location is the same as the current time in the entire zone. However, this does not necessarily hold for periods before 1970. That is, the time zone rules are only guaranteed to be correct for the named location for times before 1970; if there were time differences within the area before 1970, the time zone rules only apply in the named location for that period.

Examples

Example zone and rule lines

These are rule lines for the standard United States daylight saving time rules, rule lines for the daylight saving time rules in effect in the US Eastern Time Zone in some years, and zone lines for the America/New_York timezone, as of release version tzdata2011n of the time zone database. The zone and rule lines reflect the history of DST in the United States.

  1. Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule US 1918 1919 - Mar lastSun 2:00 1:00 D
Rule US 1918 1919 - Oct lastSun 2:00 0 S
Rule US 1942 only - Feb 9 2:00 1:00 W # War
Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace
Rule US 1945 only - Sep 30 2:00 0 S
Rule US 1967 2006 - Oct lastSun 2:00 0 S
Rule US 1967 1973 - Apr lastSun 2:00 1:00 D
Rule US 1974 only - Jan 6 2:00 1:00 D
Rule US 1975 only - Feb 23 2:00 1:00 D
Rule US 1976 1986 - Apr lastSun 2:00 1:00 D
Rule US 1987 2006 - Apr Sun>=1 2:00 1:00 D
Rule US 2007 max - Mar Sun>=8 2:00 1:00 D
Rule US 2007 max - Nov Sun>=1 2:00 0 S
....
  1. Rule NAME FROM TO TYPE IN ON AT SAVE LETTER
Rule NYC 1920 only - Mar lastSun 2:00 1:00 D
Rule NYC 1920 only - Oct lastSun 2:00 0 S
Rule NYC 1921 1966 - Apr lastSun 2:00 1:00 D
Rule NYC 1921 1954 - Sep lastSun 2:00 0 S
Rule NYC 1955 1966 - Oct lastSun 2:00 0 S
  1. Zone NAME GMTOFF RULES FORMAT
Zone America/New_York -4:56:02 - LMT 1883 November 18, 12:03:58
-5:00 US E%sT 1920
-5:00 NYC E%sT 1942
-5:00 US E%sT 1946
-5:00 NYC E%sT 1967
-5:00 US E%sT

Data stored for each zone

For each timezone that has multiple offsets, the tz database records the exact moment of transition. The format can accommodate changes in the dates and times of transitions as well. Zones may have historical rule changes going back many decades.

Zone.tab

The file zone.tab is in the public domain and lists the zones. Columns and row sorting are described in the comments of the file, as follows:
# This file contains a table with the following columns:
# 1. ISO 3166 2-character country code. See the file `iso3166.tab'.
# 2. Latitude and longitude of the zone's principal location
# in ISO 6709 sign-degrees-minutes-seconds format,
# either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
# first latitude, then longitude.
# 3. Zone name used in value of TZ environment variable.
# 4. Comments; present if and only if the country has multiple rows.
#
#
Columns are separated by a single tab.
# The table is sorted first by country, then an order within the country that
# makes some geographical sense, and
# puts the most populous zones first, where that does not contradict.

Data before 1970

Data before 1970 aims to be correct for the city identifying the region, but is not necessarily correct for the entire region. This is because new regions are created only as required to distinguish clocks since 1970.
For example, between 1963-10-23 and 1963-12-09 in Brazil only the states of Minas Gerais, Espírito Santo, Rio de Janeiro, and São Paulo had summer time. However, a requested split from America/Sao_Paulo was rejected in 2010 with the reasoning that, since 1970, the clocks were the same in the whole region.
Time in Germany, which is represented by Europe/Berlin, is incorrect for the year 1945 when the Trizone used daylight saving time rules different from Berlin's.

Coverage

Zones covering multiple post-1970 countries

There are two zones that cover an area that was covered by two countries after 1970. The database follows the definitions of countries as per ISO 3166-1, whose predecessor, ISO 3166, was first published in 1974.