Standardcore
IANA time zone database
Also called tz database, tzdb, tzdata, zoneinfo, Olson database, IANA Time Zone Database, TZif.
The IANA time zone database (tzdb) records the history of local time for regions of the world. Systems compile it into TZif files, and programs name its zones with IDs such as America/Chicago.
What it is
The IANA time zone database, also called tz, tzdb or zoneinfo, is the shared record of the local time of the world. The IANA page says that it "contains code and data that represent the history of local time for many representative locations worldwide."1 It is "updated periodically to reflect changes made by political bodies to time zone boundaries, UTC offsets, and daylight-saving rules."1 The data is in the public domain.
Each zone of the database has a name such as America/Chicago, and the zone holds all the offsets and abbreviations that the region has used, with the instants of each change. "Each main entry in the database represents a timezone for a set of civil-time clocks that have all agreed since 1970."2 A program that needs the local time of a place asks the database with such a name. See Time zone for the concept.
Almost all systems use it. The tz page lists among its users the GNU C Library, Android, the BSDs, macOS, iOS, Microsoft Windows and Oracle Database2. Java, Python, Go, .NET, C++ and the JavaScript engines read it or ship a copy of it.
Syntax or structure
Names. A name has the form Area/Location. "Timezones are typically identified by continent or ocean and then by the name of the largest city within the region containing the clocks."2 The areas are continents, oceans and Etc. Underscores replace spaces, as in America/New_York3. The names are not tied to countries, so that they stay "robust in the presence of political changes."4 When a city name changes, the old name stays as a link: "for example, in 2008 Asia/Calcutta was renamed to Asia/Kolkata due to long-time widespread use of the new city name instead of the old."4 Older names such as US/Central are links in the file backward.
Source files. The data is text, in files named after regions such as northamerica and europe. It has three kinds of line. A Rule line states when the clocks change for one or more years. A Zone line states an offset and the rules that apply to it, up to an instant. A Link line makes one name an alias of another. The Rule lines for Chicago start as follows5:
#Rule NAME FROM TO - IN ON AT SAVE LETTER
Rule Chicago 1920 only - Jun 13 2:00 1:00 D
Rule Chicago 1920 1921 - Oct lastSun 2:00 0 S
Rule Chicago 1922 1966 - Apr lastSun 2:00 1:00 D
"The FROM and TO columns, respectively, specify the first and last calendar years defining a contiguous range over which a specific Rule line is to apply."5 The column ON accepts a day number, lastSun or a form such as Sun>=8, which means the first Sunday on or after the 8th. SAVE is the amount added to standard time, and LETTER fills the %s in an abbreviation such as C%sT.
The Zone lines of Chicago start with its local mean time5:
#Zone NAME STDOFF RULES FORMAT [UNTIL]
Zone America/Chicago -5:50:36 - LMT 1883 Nov 18 12:09:24
-6:00 US C%sT 1920
-6:00 Chicago C%sT 1936 Mar 1 2:00
-5:00 - EST 1936 Nov 15 2:00
-6:00 Chicago C%sT 1942
The how-to guide explains that "each line of a Zone represents a steady state, not a transition between states."5 Each line holds from the UNTIL of the line before it to its own UNTIL, and the last line has no UNTIL. "The first line typically specifies the mean solar time observed before the introduction of standard time."5
Compiled files. The compiler zic turns the source into one binary file for each zone. RFC 9636 defines this Time Zone Information Format, TZif: "It is a binary format used by most UNIX systems to calculate local time."6 A file starts with the four bytes TZif and a version byte. It holds a list of transition instants, a table of local time types (an offset, a DST flag and an abbreviation), and, from version 2, a footer with a POSIX TZ string for the instants after the last transition. The version 1 data block has 32-bit transition times, which "are limited to representing time changes from 1901-12-13 20:45:52 through 2038-01-19 03:14:07 UT"6, so version 2 and later add a second block with 64-bit times. "The standard path for the timezone database is /usr/share/zoneinfo/ in Linux distributions, macOS, and some other Unix-like systems."3
Examples
The Python program below reads Rule lines in the source format and computes the date of each change in 1950 and 2024. It then checks each date against the compiled data that zoneinfo reads, with the abbreviation at 00:30 and at 03:30 local time on that day.
import calendar
from datetime import date, datetime
from zoneinfo import ZoneInfo
# Rule lines in the source format of the tz database (NAME FROM TO - IN ON AT SAVE LETTER).
RULES = """
Rule Chicago 1922 1966 - Apr lastSun 2:00 1:00 D
Rule Chicago 1922 1954 - Sep lastSun 2:00 0 S
Rule Chicago 1955 1966 - Oct lastSun 2:00 0 S
Rule US 2007 max - Mar Sun>=8 2:00 1:00 D
Rule US 2007 max - Nov Sun>=1 2:00 0 S
"""
MONTHS = {m: i for i, m in enumerate(calendar.month_abbr) if m}
DAYS = {d: i for i, d in enumerate(calendar.day_abbr)}
def on_day(year, month, on):
"""Returns the date that an ON field such as lastSun, Sun>=8 or 15 names."""
if on.startswith("last"):
last = calendar.monthrange(year, month)[1]
d = date(year, month, last)
while d.weekday() != DAYS[on[4:]]:
d = d.replace(day=d.day - 1)
return d
if ">=" in on:
name, low = on.split(">=")
d = date(year, month, int(low))
while d.weekday() != DAYS[name]:
d = d.replace(day=d.day + 1)
return d
return date(year, month, int(on))
chicago = ZoneInfo("America/Chicago")
for year in (1950, 2024):
for line in RULES.strip().splitlines():
_, name, start, end, _, month, on, at, save, letter = line.split()
end = 9999 if end == "max" else int(end)
if not int(start) <= year <= end:
continue
d = on_day(year, MONTHS[month], on)
# Check the date against the compiled data: the abbreviation at 00:30 and at 03:30 local time.
before = datetime(d.year, d.month, d.day, 0, 30, tzinfo=chicago).tzname()
after = datetime(d.year, d.month, d.day, 3, 30, tzinfo=chicago).tzname()
print(name, year, month, on, "->", d, before, "->", after)
Chicago 1950 Apr lastSun -> 1950-04-30 CST -> CDT
Chicago 1950 Sep lastSun -> 1950-09-24 CDT -> CST
US 2024 Mar Sun>=8 -> 2024-03-10 CST -> CDT
US 2024 Nov Sun>=1 -> 2024-11-03 CDT -> CST
The example files show one zone at three instants in each language: 1880 with the local mean time -5:50:36, 1936 with EST and no daylight saving time, and 2024 with CDT. They also load the link name Europe/Vatican, which points to Europe/Rome. The C# example shows the mapping between IANA names and the zone IDs of Windows.
from datetime import datetime, timezone
from zoneinfo import ZoneInfo, available_timezones
chicago = ZoneInfo("America/Chicago")
# Three instants in the history of one zone: local mean time, a year of EST, and today's rules.
for when in (datetime(1880, 1, 1, 12), datetime(1936, 6, 1, 12), datetime(2024, 7, 1, 12)):
t = when.replace(tzinfo=timezone.utc).astimezone(chicago)
print(t.isoformat(), t.tzname())
# Europe/Vatican is a link (an alias) to Europe/Rome. It gives the same offsets.
vatican, rome = ZoneInfo("Europe/Vatican"), ZoneInfo("Europe/Rome")
t = datetime(2024, 7, 1, 12, tzinfo=timezone.utc)
print(vatican.key, t.astimezone(vatican).utcoffset() == t.astimezone(rome).utcoffset())
print("America/Chicago" in available_timezones())
1880-01-01T06:09:24-05:50:36 LMT
1936-06-01T07:00:00-05:00 EST
2024-07-01T07:00:00-05:00 CDT
Europe/Vatican True
True
- Verdict: stdlib.
zoneinfo.ZoneInforeads the compiled files of the system, or the package tzdata from PyPI. One zone gives local mean time before 1883, EST in 1936 and CDT today, because the file holds the whole history. A link name such asEurope/Vaticanloads the same rules asEurope/Romeunder its own key.
#include <algorithm>
#include <chrono>
#include <format>
#include <iostream>
int main() {
using namespace std::chrono;
// get_tzdb() loads the tz database once, from the system or from a copy in the library.
const tzdb& db = get_tzdb();
const time_zone* chicago = db.locate_zone("America/Chicago");
for (sys_days day : {sys_days{1936y / 6 / 1}, sys_days{2024y / 7 / 1}}) {
sys_seconds t = day + 12h;
sys_info info = chicago->get_info(t);
std::cout << std::format("{:%Y-%m-%dT%H:%M:%S} {} {}\n", chicago->to_local(t), info.abbrev,
info.offset.count());
}
// Europe/Vatican is a time_zone_link. locate_zone follows the link to the zone.
auto link = std::ranges::find(db.links, "Europe/Vatican", &time_zone_link::name);
std::cout << link->name() << " -> " << link->target() << "\n";
std::cout << db.locate_zone("Europe/Vatican")->name() << "\n";
}
1936-06-01T07:00:00 EST -18000
2024-07-01T07:00:00 CDT -18000
Europe/Vatican -> Europe/Rome
Europe/Rome
- Verdict: stdlib. Since C++20,
std::chrono::get_tzdb()returns the database as a value, with a list oftime_zoneobjects and a list oftime_zone_linkobjects.get_inforeturns the offset, the abbreviation and the range of the rule for an instant. The example starts at 1936, because in a test with GCC 15 the library gave the offset -14964 seconds (-4:09:24) for Chicago in 1880, not -21036 seconds (-5:50:36).
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.zone.ZoneRules;
public class Main {
public static void main(String[] args) {
ZoneId chicago = ZoneId.of("America/Chicago");
ZoneRules rules = chicago.getRules();
// The rules hold the whole history of the zone: local mean time, a year of EST, and today's rules.
for (String iso : new String[] {"1880-01-01T12:00:00Z", "1936-06-01T12:00:00Z", "2024-07-01T12:00:00Z"}) {
Instant t = Instant.parse(iso);
System.out.println(ZonedDateTime.ofInstant(t, chicago).toLocalDateTime() + " " + rules.getOffset(t));
}
// The next change after a given instant, as the tz data gives it.
System.out.println(rules.nextTransition(Instant.parse("2024-01-01T00:00:00Z")));
// Europe/Vatican is a link to Europe/Rome in the tz data.
Instant t = Instant.parse("2024-07-01T12:00:00Z");
System.out.println(ZoneId.of("Europe/Vatican").getRules().getOffset(t).equals(ZoneId.of("Europe/Rome").getRules().getOffset(t)));
System.out.println(ZoneId.getAvailableZoneIds().contains("America/Chicago"));
}
}
1880-01-01T06:09:24 -05:50:36
1936-06-01T07:00 -05:00
2024-07-01T07:00 -05:00
Transition[Gap at 2024-03-10T02:00-06:00 to -05:00]
true
true
- Verdict: stdlib. The JDK compiles the tz data into its own file, so the version of the data changes with updates of the JDK, not of the system.
ZoneRulesgives the offset for an instant and the next or previous transition.ZoneId.ofaccepts link names such asEurope/Vatican.
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* Days from 1970-01-01 to a date of the proleptic Gregorian calendar. */
static long long days_from_civil(long long y, int m, int d) {
y -= m <= 2;
long long era = (y >= 0 ? y : y - 399) / 400;
long long yoe = y - era * 400;
long long doy = (153 * (m + (m > 2 ? -3 : 9)) + 2) / 5 + d - 1;
long long doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
return era * 146097 + doe - 719468;
}
/* Prints local time and the offset in seconds. The offset is local time minus UTC, both counted as seconds. */
static void show(time_t t) {
struct tm tm;
char buf[64];
localtime_r(&t, &tm);
long long local = days_from_civil(tm.tm_year + 1900LL, tm.tm_mon + 1, tm.tm_mday) * 86400
+ tm.tm_hour * 3600 + tm.tm_min * 60 + tm.tm_sec;
long long off = local - (long long)t;
strftime(buf, sizeof buf, "%Y-%m-%dT%H:%M:%S %Z", &tm);
printf("%s %+lld\n", buf, off);
}
int main(void) {
/* C reaches the tz database only through TZ: a zone name makes localtime read its compiled file. */
setenv("TZ", "America/Chicago", 1);
tzset();
/* 1880-01-01, 1936-06-01 and 2024-07-01, each at 12:00 UTC. */
const time_t instants[] = {-2840097600, -1059825600, 1719835200};
for (int i = 0; i < 3; i++) {
show(instants[i]);
}
/* A link name works the same way: Europe/Vatican is a link to Europe/Rome. */
setenv("TZ", "Europe/Vatican", 1);
tzset();
show(instants[2]);
return 0;
}
1880-01-01T06:09:24 LMT -21036
1936-06-01T07:00:00 EST -18000
2024-07-01T07:00:00 CDT -18000
2024-07-01T14:00:00 CEST +7200
- Verdict: stdlib. ISO C has no zone names. On POSIX systems,
TZset to a name such asAmerica/Chicagomakeslocaltimeread the compiled file of that zone. The example computes the offset itself, because%zofstrftimedoes not give the offset of each instant on all systems. The offset -21036 seconds is -5:50:36.
using System;
using System.Globalization;
// On Linux and macOS, .NET reads the compiled tz files of the system.
var chicago = TimeZoneInfo.FindSystemTimeZoneById("America/Chicago");
foreach (var day in new[] { new DateTime(1880, 1, 1), new DateTime(1936, 6, 1), new DateTime(2024, 7, 1) })
{
var t = new DateTimeOffset(day.AddHours(12), TimeSpan.Zero);
var local = TimeZoneInfo.ConvertTime(t, chicago);
Console.WriteLine(local.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture) + " " + local.Offset);
}
// Windows has its own zone IDs. .NET maps between them and the IANA names.
TimeZoneInfo.TryConvertIanaIdToWindowsId("America/Chicago", out string? windows);
Console.WriteLine(windows);
TimeZoneInfo.TryConvertWindowsIdToIanaId("Central Standard Time", out string? iana);
Console.WriteLine(iana);
1880-01-01T06:09:00 -05:51:00
1936-06-01T07:00:00 -05:00:00
2024-07-01T07:00:00 -05:00:00
Central Standard Time
America/Chicago
- Verdict: stdlib.
TimeZoneInfo.FindSystemTimeZoneByIdaccepts IANA names on Linux and macOS, and since .NET 6 also on Windows when ICU is present.TryConvertIanaIdToWindowsIdandTryConvertWindowsIdToIanaIduse the mapping data of the Unicode CLDR. ADateTimeOffsetstores its offset in whole minutes, so the offset -5:50:36 of Chicago in 1880 becomes -05:51, and the local time loses its 24 seconds.
// Intl.DateTimeFormat reads the tz database that the JavaScript engine ships with (ICU in V8).
function show(instant, timeZone) {
const f = new Intl.DateTimeFormat("en-CA", {
timeZone, year: "numeric", month: "2-digit", day: "2-digit",
hour: "2-digit", minute: "2-digit", second: "2-digit", hourCycle: "h23",
timeZoneName: "longOffset",
});
const p = Object.fromEntries(f.formatToParts(instant).map((x) => [x.type, x.value]));
return `${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}:${p.second} ${p.timeZoneName}`;
}
for (const iso of ["1880-01-01T12:00:00Z", "1936-06-01T12:00:00Z", "2024-07-01T12:00:00Z"]) {
console.log(show(new Date(iso), "America/Chicago"));
}
// A link name gives the same local time as the zone it points to.
const t = new Date("2024-07-01T12:00:00Z");
console.log(show(t, "Europe/Vatican") === show(t, "Europe/Rome"));
console.log(Intl.supportedValuesOf("timeZone").includes("America/Chicago"));
1880-01-01 06:09:24 GMT-05:50:36
1936-06-01 07:00:00 GMT-05:00
2024-07-01 07:00:00 GMT-05:00
true
true
- Verdict: native. The engine ships its own copy of the tz data, which ICU holds in V8 and SpiderMonkey.
Intl.DateTimeFormatwith the optiontimeZoneuses the full history, so the offset in 1880 has seconds.Intl.supportedValuesOflists the zone names that the engine knows.
package main
import (
"fmt"
"time"
)
func main() {
// LoadLocation reads the zone from the tz data of the system, or from time/tzdata if the program embeds it.
chicago, err := time.LoadLocation("America/Chicago")
if err != nil {
fmt.Println("error:", err)
return
}
for _, s := range []string{"1880-01-01T12:00:00Z", "1936-06-01T12:00:00Z", "2024-07-01T12:00:00Z"} {
t, _ := time.Parse(time.RFC3339, s)
fmt.Println(t.In(chicago).Format("2006-01-02T15:04:05-07:00:00 MST"))
}
// Europe/Vatican is a link to Europe/Rome. The Location keeps the name it was loaded with.
vatican, _ := time.LoadLocation("Europe/Vatican")
rome, _ := time.LoadLocation("Europe/Rome")
t := time.Date(2024, 7, 1, 12, 0, 0, 0, time.UTC)
_, a := t.In(vatican).Zone()
_, b := t.In(rome).Zone()
fmt.Println(vatican, a == b)
}
1880-01-01T06:09:24-05:50:36 LMT
1936-06-01T07:00:00-05:00:00 EST
2024-07-01T07:00:00-05:00:00 CDT
Europe/Vatican true
- Verdict: stdlib.
time.LoadLocationreads the compiled file of the zone from the system. A program that imports the packagetime/tzdataembeds a copy of the data, so it also runs on a system with no zone files. TheLocationkeeps the name it was loaded with, so a link prints its own name.
# A zone name in TZ makes the C library read the compiled file of the zone.
in_zone() (
export TZ=$1
printf '%(%Y-%m-%dT%H:%M:%S%z %Z)T\n' "$2"
)
# 1880-01-01, 1936-06-01 and 2024-07-01, each at 12:00 UTC.
for t in -2840097600 -1059825600 1719835200; do
in_zone America/Chicago "$t"
done
# Europe/Vatican is a link to Europe/Rome.
in_zone Europe/Vatican 1719835200
# The compiled files are in a directory such as /usr/share/zoneinfo.
[ -f /usr/share/zoneinfo/America/Chicago ] && echo "file found"
1880-01-01T06:09:24-0550 LMT
1936-06-01T07:00:00-0500 EST
2024-07-01T07:00:00-0500 CDT
2024-07-01T14:00:00+0200 CEST
file found
- Verdict: idiom. Bash has no zone type. A zone name in the variable
TZselects a compiled file of the tz database forprintf '%(...)T'and for the commanddate. The offset -0550 drops the 36 seconds of the real offset, because%zhas no field for seconds.
Versions
The database has no version numbers in the usual sense. Each release has the name of its year and a letter, and the IANA page shows the latest release, such as "Latest version 2026f Released 2026-10-27"1. "New editions of the database and code are published as changes warrant, usually several times per year."3 A release can change the present: the summary of 2026f starts with "Cuba will not fall back 2026-11-01"1, which was 5 days after the release.
The TZif format has versions 1 to 4. The format dates from the 1980s, and RFC 9636 obsoletes RFC 8536, the first RFC for it6. Version 2 added the 64-bit data and the footer.
The process has its own rules. RFC 6557 states "procedures involved with maintenance of the TZ database and associated code, including how to submit proposed updates, how decisions for inclusion of those updates are made, and the selection of a designated expert by and for the time zone community."7 It defines the TZ Coordinator as "The person or people who maintain and manage release of the TZ Database."7
The project goes back to 1986 or earlier, and its founding contributor was Arthur David Olson3. Paul Eggert has been its editor since 2005. On 30 September 2011 a lawsuit about copyright in the data was filed, and the mailing list and the FTP site were shut down. ICANN took over the maintenance on 14 October 2011, and the lawsuit was resolved on 22 February 20123.
Pitfalls
- Old data on the machine. A program uses the copy of the data that its platform has. Java has its own copy in the JDK, the JavaScript engines have one in ICU, and Python, Go and C read the files of the system. "End users typically receive updates to this data through their software and operating system vendors."1 After a government changes its rules, two machines can give different local times for the same instant until both are updated.
- History before 1970 is partial. The database records transitions before 1970 for its zones, "because most systems support timestamps before 1970 and could misbehave if data entries were omitted for pre-1970 transitions. However, the database is not designed for and does not suffice for applications requiring accurate handling of all past times everywhere"4. Two cities that share a zone since 1970 can have different clocks before 1970.
- Names are not stable keys for people. Names change when city names change, and old names become links. Store the name, but do not show it as the name of a country or compare names as text to decide if two zones are equal. Compare offsets at the instants that matter, or resolve links first.
- Old names missing on the system. Some Linux distributions put the old names of the file
backwardin a separate package, such astzdata-legacyon Debian and Ubuntu. On the Ubuntu 24.04 server that ran these examples,ZoneInfo("US/Central")in Python failed andTZ=US/Centralin C fell back to UTC with no error, while Java, JavaScript, Go and C++ found the name in other copies of the data. Store the current name, such asAmerica/Chicago. - Offsets with seconds. Local mean time offsets such as -5:50:36 have seconds. A format with
%z, or a type that stores whole minutes, loses them. The Bash example shows -0550, and theDateTimeOffsetof the C# example shows -05:51. - The 32-bit limit. A program that reads only the version 1 block of a TZif file gets no transitions after 2038-01-19. Read the version 2 block and the footer. See Unix time for the year 2038 problem.
- Windows zone IDs. Windows has its own set of zone IDs, such as
Central Standard Time, and fewer zones than the IANA database. A mapping between them "cannot be perfect because the number of time zones in Windows systems is significantly lower than in the IANA TZ database."3 - Abbreviations are not keys. The database has abbreviations for display. Many are invented or shared by several zones. Parse zone names, not abbreviations.
Tools and libraries
- Python:
zoneinfo.ZoneInforeads the system files. "By default, zoneinfo uses the system's time zone data if available; if no system time zone data is available, the library will fall back to using the first-party tzdata package available on PyPI."8 - Go:
time.LoadLocationsearches "the directory or uncompressed zip file named by the ZONEINFO environment variable"9, then the system, then$GOROOT/lib/time/zoneinfo.zip, then the packagetime/tzdataif the program imports it9. - C++: "The class tzdb represents a copy of the IANA time zone database."10
std::chrono::get_tzdb()returns it, with itsversion, its zones and its links. - .NET:
TimeZoneInfo.FindSystemTimeZoneByIdaccepts IANA names, andTryConvertIanaIdToWindowsId"Tries to convert an IANA time zone ID to a Windows ID."11 - Java:
java.timehas its own compiled copy of the data, and the JDK tool tzupdater updates it. - The reference code of the project has the compiler
zicand the dumperzdump.zdump -v America/Chicagoprints each transition of a zone.
References
- Time Zone Database, IANA, Introduction; Latest version
- Time zone and daylight saving time data, IANA, Introduction; The tz database
- tz database, Wikipedia, Introduction; Names of timezones; Unix-like systems; History
- Theory and pragmatics of the tz code and data, IANA, Scope of the tz database; Timezone identifiers
- Bill Seymour, How to Read the tz Database Source Files, IANA, Rule lines; Zone lines
- A. Olson, P. Eggert, K. Murchison, RFC 9636: The Time Zone Information Format (TZif), October 2024, 1 Introduction; 3 The Time Zone Information Format; 3.1 TZif Header
- E. Lear, P. Eggert, RFC 6557: Procedures for Maintaining the Time Zone Database, February 2012, Abstract; 2 Terminology
- zoneinfo, IANA time zone support, The Python Standard Library, Data sources
- Package time, Go standard library, func LoadLocation
- std::chrono::tzdb, cppreference.com, Description; Member objects
- TimeZoneInfo Class, .NET API, Methods
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W3 standard |
|
Tag YQXK5P Edit this page History Report an error Markdown