Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@js-joda/timezone

js-joda661.6kBSD-3-Clause2.22.0TypeScript support: included

iana tzdb timezone bindings for js-joda

date, time, timezone

readme

@js-joda/timezone

npm version GH Actions Build Status Sauce Test Status Coverage Status Downloads/Month

Sauce Browser Matrix

Motivation

Implementation of the js-joda ZoneRulesProvider, providing the bindings to the iana tzdb, using latest zone file generated by moment-timezone

Usage

Node

Install joda using npm

npm install @js-joda
npm install @js-joda/timezone

es5

var jsJoda = require('@js-joda/core')
require('@js-joda/timezone')

var { LocalDateTime, ZoneId, ZonedDateTime } = jsJoda;

LocalDateTime
    .parse('2016-06-30T11:30')
    .atZone(ZoneId.of('Europe/Berlin'))
    .toString()  // 2016-06-30T11:30+02:00[Europe/Berlin]

ZonedDateTime
    .parse('2016-06-30T11:30+02:00[Europe/Berlin]') 
    .withZoneSameInstant(ZoneId.of('America/New_York'))
    .toString() // 2016-06-30T05:30-04:00[America/New_York]

ZonedDateTime
    .parse('2016-06-30T11:30+02:00[Europe/Berlin]')
    .withZoneSameLocal(ZoneId.of('America/New_York'))
    .toString() // 2016-06-30T11:30-04:00[America/New_York]

es6 / typescript

import { ZonedDateTime, ZoneId } from '@js-joda/core'
import '@js-joda/timezone'

const zdt = ZonedDateTime.now(ZoneId.of('America/New_York'))

Browser

<script src="./packages/core/dist/js-joda.js"></script>
<script src="./packages/timezone/dist/js-joda-timezone.js"></script>
<script>
    // copy all js-joda classes to the global scope
    for(let key in JSJoda) { this[key] = JSJoda[key]; }

    LocalDateTime
        .parse('2016-06-30T11:30')
        .atZone(ZoneId.of('Europe/Berlin'))
        .toString()  // 2016-06-30T11:30+02:00[Europe/Berlin]

    ZonedDateTime
        .parse('2016-06-30T11:30+02:00[Europe/Berlin]') 
        .withZoneSameInstant(ZoneId.of('America/New_York'))
        .toString() // 2016-06-30T05:30-04:00[America/New_York]

    ZonedDateTime
        .parse('2016-06-30T11:30+02:00[Europe/Berlin]')
        .withZoneSameLocal(ZoneId.of('America/New_York'))
        .toString() // 2016-06-30T11:30-04:00[America/New_York]
</script>

Reducing js-joda-timezone file size

If you don't need all the historical data that @js-joda/timezone provides, you can instead use one of the reduced files ize builds:

  • js-joda-timezone-10-year-range.js covers +- five years from the current version's release
  • js-joda-timezone-1970-2030.js covers from 1970 to 2030
  • js-joda-timezone-2012-2022.js covers from 2012 to 2022 // deprecated, will be removed in future releases
  • js-joda-timezone-2017-2027.js covers from 2017 to 2027

To use one of these, just change your import path to the following format:

import '@js-joda/timezone/dist/js-joda-timezone-1970-2030'

Implementation details

  • This ZoneRulesProvider implemantion supplies all functionality that is required by the js-joda package.
  • Additional ZoneRules functionality like transitions(), etc. is not implemented.

License

  • @js-joda/timezone is released under the BSD 3-clause license:

  • The author of joda time and the lead architect of the JSR-310 is Stephen Colebourne.

  • The json versions of the iana tzdb are imported from and generated with moment-timezone.

changelog

Changelog

Later version

For later versions check the global CHANGELOG.md file in the root folder.

2.11.0

2.10.0

2.9.0

  • #567 Remove generated distributions files from git (@pithu)
  • #564 Fix travis for PR's from forks (@pithu)

2.8.0

  • #561 Update @js-joda/timezone to tzdb 2021c (@pithu)

2.7.0

  • Upgrade dependencies #555 by @pithu
  • Change @babel/preset-env targets, fix IE11 issues #555 by @pithu

2.6.0

  • updated to iana tzdb 2021a

2.5.0

  • updated to iana tzdb 2020d

2.4.0

  • updated to iana tzdb 2020c

2.3.0

  • updated to iana tzdb 2020a

2.2.1

  • Update js-joda peer dependency

2.2.0

  • updated to iana tzdb 2019c #362
  • npm audit fix

2.1.1

  • Update js-joda peer dependency

2.1.0

  • produce smaller builds containing a more limited set of timezone data #73
  • updated to iana tzdb 2019a #73

2.0.2

  • updated to iana tzdb 2018g

2.0.1

  • iana tzdb 2018e

2.0.0

public API

(re) introduced new plugin concept

  • Hide use(plug) concept from public api. The function for extending js-joda is not exported anymore (the default export of this module is removed). The code for extending js-joda use(plug) is not required anymore, because @js-joda/timezone automaticaly extends js-joda when imported.

dependendency updates

1.3.1

revert previous (breaking) public API change (see https://github.com/js-joda/js-joda-timezone/issues/48)

1.3.0

public api

  • Hide use(plug) concept from public api. The function for extending js-joda is not exported anymore (the default export of this module is removed). The code for extending js-joda use(plug) is not required anymore, because js-joda-timezone automaticaly extends js-joda when imported.

1.2.1

bug

  • fix umd build

dependendency updates

1.2.0

public api

  • remove private export of tzdb data, instead
  • add loadTzdbData() and getTzdbData() static methods to the class ZoneRulesProvider, that allows to provide/share tzdb data.
  • provide empty dist versions of js-joda-timezone without preconfigured tzdb data.

iana tzdb

  • manually updated iana tzdb to 2018c

dependendency updates

1.1.6

dependendency updates

etc

  • private export of tzdb data

1.1.5

etc

  • add bower.json

dependendency updates

1.1.3

dependendency updates

1.1.2

add typescript definition

dependency updates

1.1.1

last release without a CHANGELOG.md