IANA Time Zone Data for North America

1.0.48 · active · verified Wed Apr 22

This package provides a machine-readable JSON representation of the 'northamerica' region from the official IANA Time Zone Database (TZDB). It is a pure data package, offering a static snapshot of time zone rules and historical offsets specific to North American regions, intended for consumption by time zone calculation libraries rather than performing computations itself. The current stable version, 1.0.48, reflects the IANA TZDB 2026a release. The package follows the IANA TZDB release cadence, typically updating several times a year to incorporate geopolitical changes to time zones (e.g., changes in DST rules, country-wide offset shifts). Its key differentiator among similar data packages is its focus on a specific geographical subset, leading to a smaller footprint for applications that only require North American time zone data, and its direct JSON format which is easy to parse.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and access time zone data for North American zones in a Node.js environment. It shows how to retrieve the raw JSON data for specific zones like 'America/New_York' and 'America/Los_Angeles', and illustrates that non-North American zones will not be present in this package. It also hints at how this data would be integrated with a time zone calculation library.

import jsonData from 'tzdata-northamerica';

// Access specific time zone data by IANA name
const newYorkData = jsonData['America/New_York'];
const losAngelesData = jsonData['America/Los_Angeles'];

console.log('--- Time Zone Data for America/New_York ---');
if (newYorkData) {
  // The data structure is an object where keys might represent years or rule sets.
  // This example just shows a simplified view of its content.
  console.log(`America/New_York data is available. It has ${Object.keys(newYorkData).length} top-level entries.`);
  const firstKey = Object.keys(newYorkData)[0];
  if (firstKey) {
    console.log(`First entry for America/New_York (key: ${firstKey}):`, newYorkData[firstKey]);
  }
} else {
  console.log('Error: America/New_York data not found. This should not happen with tzdata-northamerica.');
}

console.log('\n--- Time Zone Data for America/Los_Angeles ---');
if (losAngelesData) {
  console.log(`America/Los_Angeles data is available. It has ${Object.keys(losAngelesData).length} top-level entries.`);
} else {
  console.log('Error: America/Los_Angeles data not found. This should not happen with tzdata-northamerica.');
}

// Attempting to access a non-North American zone will result in undefined
const berlinData = jsonData['Europe/Berlin'];
console.log('\nAttempting to access Europe/Berlin (not in this package):', berlinData);
// Expected output for Berlin: undefined

// To use this data meaningfully, typically you'd pass it to a library like timezonecomplete.
// Example (conceptual, requires timezonecomplete setup):
// import { TzDatabase, DateTime } from 'timezonecomplete';
// TzDatabase.init([jsonData]); // Initialize with the loaded data
// const nowInNYC = new DateTime('now', 'America/New_York');
// console.log('Current time in New York (conceptual):', nowInNYC.toString());

view raw JSON →