6.161.0 • Published 5 months ago

@vvo/tzdb v6.161.0

Weekly downloads
19,058
License
MIT
Repository
github
Last release
5 months ago

tzdb GitHub license Tests npm version minizipped size

This is a list and npm package of:

  • "simplified" IANA time zones with their alternative names like Pacific Time instead of America/Los_Angeles, along with major cities for each time zone.
  • all existing raw IANA time zones names
  • "raw" offsets along with current time offsets
  • also includes deprecated time zone names for compatibility

The data and npm packages are automatically updated whenever there are changes to https://www.geonames.org/ which is generated from IANA databases.

This is useful whenever you want to build a time zone select menu in your application.

NPM package

Installation:

npm add @vvo/tzdb

Usage:

import { getTimeZones, rawTimeZones, timeZonesNames, abbreviations } from "@vvo/tzdb";

API

getTimeZones()

const timeZones = getTimeZones();

// You can also provide an optional parameter to include UTC in the result.
// This adds a time zone with the name "UTC" and a fixed offset of 0.
const timeZonesWithUtc = getTimeZones({ includeUtc: true });

This method returns an array of time zones objects:

[
  // ...
  {
    name: "America/Los_Angeles",
    alternativeName: "Pacific Time",
    group: ["America/Los_Angeles"],
    continentCode: "NA",
    continentName: "North America",
    countryName: "United States",
    countryCode: "US",
    mainCities: ["Los Angeles", "San Diego", "San Jose", "San Francisco"],
    rawOffsetInMinutes: -480,
    abbreviation: "PST",
    rawFormat: "-08:00 Pacific Time - Los Angeles, San Diego, San Jose, San Francisco",
    currentTimeOffsetInMinutes: -420, // "current" time zone offset, this is why getTimeZones() is a method and not just an object: it works at runtime
    currentTimeFormat: "-07:00 Pacific Time - Los Angeles, San Diego",
  },
  // ...
];

When relevant, time zones are grouped. The rules for grouping are:

  • if the time zones are in the same country
  • if the DST or summer time offsets are the same
  • if the non-DST, non-summer time offsets are the same
  • then we group the time zones
  • the "main" time zone name (name attribute), is always the one from the most populated city

Here's a grouping example:

{
  name: "America/Dawson_Creek",
  alternativeName: "Mountain Time",
  group: ["America/Creston", "America/Dawson_Creek", "America/Fort_Nelson"],
  continentCode: "NA",
  continentName: "North America",
  countryName: "Canada",
  countryCode: "CA",
  mainCities: ["Fort St. John", "Creston", "Fort Nelson"],
  rawOffsetInMinutes: -420,
  abbreviation: "MST",
  rawFormat: "-07:00 Mountain Time - Fort St. John, Creston, Fort Nelson",
  currentTimeOffsetInMinutes: -420,
  currentTimeFormat: "-07:00 Mountain Time - Fort St. John, Creston"
}

rawTimeZones

This is an array of time zone objects without the current time information:

[
  // ...
  {
    name: "America/Los_Angeles",
    alternativeName: "Pacific Time",
    group: ["America/Los_Angeles"],
    continentCode: "NA",
    continentName: "North America",
    countryName: "United States",
    countryCode: "US",
    mainCities: ["Los Angeles", "San Diego", "San Jose", "San Francisco"],
    rawOffsetInMinutes: -480,
    abbreviation: "PST",
    rawFormat: "-08:00 Pacific Time - Los Angeles, San Diego, San Jose, San Francisco",
  },
  // ...
];

timeZonesNames

This is an array of time zone names:

[
  // ...
  "America/Juneau",
  "America/Kentucky/Louisville",
  "America/Kentucky/Monticello",
  "America/Kralendijk",
  "America/La_Paz",
  "America/Lima",
  "America/Los_Angeles",
  "America/Lower_Princes",
  "America/Maceio",
  "America/Managua",
  "America/Manaus",
  "America/Marigot",
  "America/Martinique",
  "America/Matamoros",
  // ...
];

abbreviations

This is an object mapping timezone abbreviations to their full forms:

{
  // ...
  "Australian Central Daylight Time": "ACDT",
  "Australian Central Standard Time": "ACST",
  "Australian Central Time": "ACT",
  "Australian Central Western Standard Time": "ACWST",
  "Australian Eastern Daylight Time": "AEDT",
  "Australian Eastern Standard Time": "AEST",
  "Australian Eastern Time": "AET",
  "Australian Western Daylight Time": "AWDT",
  "Australian Western Standard Time": "AWST",
  "Azerbaijan Summer Time": "AZST",
  "Azerbaijan Time": "AZT",
  "Azores Summer Time": "AZOST",
  "Azores Time": "AZOT",
  "Bangladesh Standard Time": "BST",
  "Bhutan Time": "BTT",
  "Bolivia Time": "BOT",
  // ...
};

Caution: Although abbreviations can be easy to lookup, they can be misleading. For example: CST can refer to Central Standard Time (-06.00 UTC), China Standard Time (+06.00 UTC) or Cuba Standard Time (-05.00 UTC). And abbreviation full forms don't directly map to any property in the time zone objects returned by rawTimeZones or getTimeZones().

Notes

  • We provide two cities when grouping happens, ranked by population
  • We provide alternative names ("Pacific Time" for "America/Los_Angeles") and remove "Standard", "Daylight" or "Summer" from them
  • If you're using this to build a time zone selector and saving to a database then:
    • make sure to save the name attribute (America/Los_Angeles) in your database
    • when displaying the select with a default value from your database, either select the time zone name that matches, or if the time zone name is part of the group. Example:
const value = timeZones.find((timeZone) => {
  return dbData.timeZone === timeZone.name || timeZone.group.includes(dbData.timeZone);
});
6.161.0

5 months ago

6.160.0

5 months ago

6.159.0

6 months ago

6.158.0

6 months ago

6.157.0

7 months ago

6.156.0

7 months ago

6.155.0

7 months ago

6.154.0

7 months ago

6.153.0

7 months ago

6.152.0

7 months ago

6.151.0

7 months ago

6.150.0

8 months ago

6.149.0

9 months ago

6.148.0

9 months ago

6.147.0

9 months ago

6.146.0

9 months ago

6.144.0

11 months ago

6.143.0

11 months ago

6.145.0

10 months ago

6.142.0

12 months ago

6.140.0

1 year ago

6.141.0

1 year ago

6.139.0

1 year ago

6.138.0

1 year ago

6.137.0

1 year ago

6.136.0

1 year ago

6.135.0

1 year ago

6.134.0

1 year ago

6.133.0

1 year ago

6.132.0

1 year ago

6.131.0

1 year ago

6.130.0

1 year ago

6.129.0

1 year ago

6.128.0

1 year ago

6.127.0

1 year ago

6.126.0

1 year ago

6.125.0

1 year ago

6.124.0

2 years ago

6.123.0

2 years ago

6.122.0

2 years ago

6.121.0

2 years ago

6.120.0

2 years ago

6.119.0

2 years ago

6.118.0

2 years ago

6.114.0

2 years ago

6.110.0

2 years ago

6.117.0

2 years ago

6.113.0

2 years ago

6.116.0

2 years ago

6.109.0

2 years ago

6.112.0

2 years ago

6.115.0

2 years ago

6.111.0

2 years ago

6.108.0

2 years ago

6.107.0

2 years ago

6.106.0

2 years ago

6.104.0

2 years ago

6.105.0

2 years ago

6.103.0

2 years ago

6.102.0

2 years ago

6.97.0

2 years ago

6.101.0

2 years ago

6.100.0

2 years ago

6.99.0

2 years ago

6.98.0

2 years ago

6.93.0

2 years ago

6.96.0

2 years ago

6.95.0

2 years ago

6.94.0

2 years ago

6.92.0

2 years ago

6.91.0

2 years ago

6.85.0

3 years ago

6.81.0

3 years ago

6.89.0

3 years ago

6.78.0

3 years ago

6.74.0

3 years ago

6.84.0

3 years ago

6.80.0

3 years ago

6.88.0

3 years ago

6.77.0

3 years ago

6.73.0

3 years ago

6.83.0

3 years ago

6.87.0

3 years ago

6.76.0

3 years ago

6.72.0

3 years ago

6.82.0

3 years ago

6.86.0

3 years ago

6.75.0

3 years ago

6.79.0

3 years ago

6.90.0

3 years ago

6.71.1

3 years ago

6.71.0

3 years ago

6.66.0

3 years ago

6.62.0

3 years ago

6.70.0

3 years ago

6.65.0

3 years ago

6.69.0

3 years ago

6.64.0

3 years ago

6.68.0

3 years ago

6.67.0

3 years ago

6.63.0

3 years ago

6.55.0

3 years ago

6.59.0

3 years ago

6.61.0

3 years ago

6.54.0

3 years ago

6.58.0

3 years ago

6.60.0

3 years ago

6.53.0

3 years ago

6.57.0

3 years ago

6.56.0

3 years ago

6.51.0

3 years ago

6.52.0

3 years ago

6.50.0

3 years ago

6.49.0

3 years ago

6.47.0

3 years ago

6.46.0

3 years ago

6.48.0

3 years ago

6.43.0

4 years ago

6.45.0

3 years ago

6.41.0

4 years ago

6.38.0

4 years ago

6.42.0

4 years ago

6.44.0

4 years ago

6.40.0

4 years ago

6.39.0

4 years ago

6.34.0

4 years ago

6.32.0

4 years ago

6.36.0

4 years ago

6.33.0

4 years ago

6.31.0

4 years ago

6.37.0

4 years ago

6.35.0

4 years ago

6.30.0

4 years ago

6.22.0

4 years ago

6.26.0

4 years ago

6.24.0

4 years ago

6.29.0

4 years ago

6.23.0

4 years ago

6.27.0

4 years ago

6.25.0

4 years ago

6.28.0

4 years ago

6.20.0

4 years ago

6.21.0

4 years ago

6.19.0

4 years ago

6.17.0

4 years ago

6.15.0

4 years ago

6.13.0

4 years ago

6.18.0

4 years ago

6.12.0

4 years ago

6.16.0

4 years ago

6.14.0

4 years ago

6.11.0

4 years ago

6.10.0

4 years ago

6.9.0

4 years ago

6.8.0

4 years ago

6.7.0

4 years ago

6.6.0

4 years ago

6.5.1

4 years ago

6.5.0

4 years ago

6.4.1

5 years ago

6.4.0

5 years ago

6.3.0

5 years ago

6.2.1

5 years ago

6.2.0

5 years ago

6.1.0

5 years ago

6.0.0

5 years ago

5.7.0

5 years ago

5.6.0

5 years ago

5.5.2

5 years ago

5.5.1

5 years ago

5.5.0

5 years ago

5.4.2

5 years ago

5.4.1

5 years ago

5.4.0

5 years ago

5.3.0

5 years ago

5.2.0

5 years ago

5.1.1

5 years ago

5.1.0

5 years ago

5.0.0

5 years ago

4.4.0

5 years ago

4.1.0

5 years ago

4.3.0

5 years ago

4.2.0

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.15.0

5 years ago

3.14.0

5 years ago

3.13.2

5 years ago

3.13.1

5 years ago

3.13.0

5 years ago

3.12.0

5 years ago

3.11.0

5 years ago

3.10.0

5 years ago

3.8.0

5 years ago

3.9.0

5 years ago

3.7.0

5 years ago

3.6.0

5 years ago

3.5.0

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago