# timezone-support

> Lightweight time zone support for your applications or other date libraries.

Latest version **3.1.0** (published 2022-12-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install timezone-support
pnpm add timezone-support
yarn add timezone-support
bun add timezone-support
```

Provides the command `create-timezone-data`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2022-12-04 |
| First published | 2018-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14.8 |
| Dependencies | 1 |
| Unpacked size | 25.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 117 |
| Author | Ferdinand Prantl |
| Maintainers | prantlf |
| Keywords | timezone, tzdata, convert, offset, date, time |

## Links

- npm: https://www.npmjs.com/package/timezone-support
- Repository: https://github.com/prantlf/timezone-support
- Homepage: https://github.com/prantlf/timezone-support#readme
- Issues: https://github.com/prantlf/timezone-support/issues
- npm.io page: https://npm.io/package/timezone-support

## Dependencies (1)

- [moment-timezone](https://npm.io/package/moment-timezone.md) 0.5.39

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2022-12-04
- 2.2.0 — 2022-12-04
- 2.1.1 — 2022-12-04
- 3.0.0 — 2022-12-04
- 2.1.0 — 2022-12-04
- 2.0.2 — 2019-06-10
- 2.0.1 — 2019-06-10
- 2.0.0 — 2019-06-10
- 1.8.1 — 2018-11-27
- 1.8.0 — 2018-11-17
- 1.7.0 — 2018-11-17
- 1.6.1 — 2018-11-17
- 1.6.0 — 2018-11-06
- 1.5.5 — 2018-10-08
- 1.5.4 — 2018-10-07
- … 15 more at https://npm.io/package/timezone-support/versions

## README

# Time Zone Support

[![Latest version](https://img.shields.io/npm/v/timezone-support)
 ![Dependency status](https://img.shields.io/librariesio/release/npm/timezone-support)
](https://www.npmjs.com/package/timezone-support)
[![Coverage](https://codecov.io/gh/prantlf/timezone-support/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/timezone-support)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9f1034029c0747a980cd49f64f16338b)](https://www.codacy.com/app/prantlf/timezone-support?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=prantlf/timezone-support&amp;utm_campaign=Badge_Grade)


Lightweight time zone listing and date converting. Intended for adding time zone support to high-level date libraries, but also for direct application usage.

* Tiny code base - 4.6 KB minified, 1.7 KB gzipped. Do not pack unnecessary weight in your application.
* Packed time zone data - 924 KB minified, 33.6 KB gzipped. Single time zones are unpacked on demand.
* Smaller bundles of code with limited data - 1900-2050 (206 kB minified, 25.4 kB gzipped), 1970-2038 (141 kB minified, 15.8 kB gzipped) and 2012-2022 (31.3 KB minified, 8.25 kB gzipped).
* Generated from the official time zone database version 2022f. Canonical time zone names, aliases, UTC offsets, and daylight-saving time changes.
* ESM, UMD and CJS module formats provided.
* Minimal interface for time zone lookup and conversions. Parsing, formatting and manipulating dates is usually the task for a higher-level date library.

**Attention**: exported identifiers in vanilla browser modules changed in the version 2.0.0. See the [migration guide] for more information.

### Table of Contents

- [Synopsis](#synopsis)
- [Installation and Getting Started](#installation-and-getting-started)
- [Usage Scenarios](./docs/usage.md#usage-scenarios)
- [Design Concepts](./docs/design.md#design-concepts)
- [API Reference](./docs/API.md#api-reference)
- [Library Integrations](#library-integrations)
- [Contributing](#contributing)
- [Release History](#release-history)
- [License](#license)

## Synopsis

```js
const {
  listTimeZones, findTimeZone, getZonedTime, getUnixTime
} = require('timezone-support')

// List canonical time zone names: [ 'Africa/Abidjan', ... ]
const timeZones = listTimeZones()

// Find a particular time zone: { name: 'Europe/Berlin', ... }
const berlin = findTimeZone('Europe/Berlin')

// Convert a date to a specific time zone: { year, month, day, dayOfWeek,
// hours, minutes, seconds, milliseconds, epoch, zone: { abbreviation, offset } }
const nativeDate = new Date()
const berlinTime = getZonedTime(nativeDate, berlin)

// Convert a time from a specific time zone: native Date object
const berlinTime = { year: 2018, month: 9, day: 2, hours: 10, minutes: 0 }
const nativeDate = new Date(getUnixTime(berlinTime, berlin))
```

## Installation and Getting Started

This module can be installed in your project using [NPM], [PNPM] or [Yarn]. Make sure, that you use [Node.js] version 14.8 or newer.

```sh
$ npm i timezone-support
$ pnpm i timezone-support
$ yarn add timezone-support
```

Functions are exposed as named exports from the package modules, for example:

```js
const { findTimeZone, getZonedTime } = require('timezone-support')
```

You can read more about the [module loading] in other environments, like with ES6 or in web browsers. [Usage scenarios] demonstrate applications of this library in typical real-world scenarios. [Design concepts] explain the approach to time zone handling taken by tni library and types of values used ion the interface. [Generating custom time zone data] will allow you to save the overall package size by limiting the supported year span. Finally, the [API reference] lists all functions with a description of their functionality.

You can see [complete sample applications] too, which can help you start with integration of this library.

## Library Integrations

* [Day.js] - [timeZone plugin] supplies parsing from and formatting to an arbitrary time zone
* [date-fns] - [date-fns-timezone] provides functions for parsing from and formatting to an arbitrary time zone and time zone conversions for the native `Date` object.

## Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.  Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

## License

Copyright (c) 2018-2022 Ferdinand Prantl

Licensed under the MIT license.

[Node.js]: http://nodejs.org/
[NPM]: https://www.npmjs.com/
[PNPM]: https://pnpm.io/
[Yarn]: https://yarnpkg.com/
[Day.js]: https://github.com/iamkun/dayjs
[date-fns]: https://github.com/date-fns/date-fns
[timeZone plugin]: https://github.com/prantlf/dayjs/blob/combined/docs/en/Plugin.md#timezone
[date-fns-timezone]: https://github.com/prantlf/date-fns-timezone
[migration guide]: docs/migration.md#migration-from-1x-to-2x
[complete sample applications]: examples#readme
[module loading]: ./docs/API.md#loading
[Usage scenarios]: ./docs/usage.md#usage-scenarios
[Design concepts]: ./docs/design.md#design-concepts
[Generating custom time zone data]: ./docs/usage.md#generate-custom-time-zone-data
[API reference]: ./docs/API.md#api-reference

---
_Source: https://npm.io/package/timezone-support · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
