js-joda-timezone

WebJar for js-joda-timezone

License

License

BSD 3-Clause
Categories

Categories

JavaScript Languages
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

js-joda-timezone
Last Version

Last Version

2.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

js-joda-timezone
WebJar for js-joda-timezone
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/js-joda/js-joda-timezone

Download js-joda-timezone

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/js-joda-timezone/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>js-joda-timezone</artifactId>
    <version>2.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/js-joda-timezone/
implementation 'org.webjars.npm:js-joda-timezone:2.1.1'
// https://jarcasting.com/artifacts/org.webjars.npm/js-joda-timezone/
implementation ("org.webjars.npm:js-joda-timezone:2.1.1")
'org.webjars.npm:js-joda-timezone:jar:2.1.1'
<dependency org="org.webjars.npm" name="js-joda-timezone" rev="2.1.1">
  <artifact name="js-joda-timezone" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='js-joda-timezone', version='2.1.1')
)
libraryDependencies += "org.webjars.npm" % "js-joda-timezone" % "2.1.1"
[org.webjars.npm/js-joda-timezone "2.1.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

!This package is deprecated!

The current version has been moved to the js-joda mono repository, see https://github.com/js-joda/js-joda

js-joda-timezone

npm version Build Status Sauce Test Status Coverage Status Tested node version

Sauce Test Status

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')
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'
import 'js-joda-timezone'

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

Browser

<script src="../dist/js-joda.js"></script>
<script src="../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

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.

org.webjars.npm

Versions

Version
2.1.1
1.3.1
1.1.5
1.1.3
1.1.1
1.0.0