🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

js-joda-timezone

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-joda-timezone

iana tzdb timezone bindings for js-joda

0.0.5
Source
npm
Version published
Weekly downloads
2K
41.88%
Maintainers
1
Weekly downloads
 
Created
Source

js-joda-timezone

bindings to the iana tzdb, using latest zone file generated by moment-timezone

Usage

Node

Install joda using npm

npm install js-joda

Then require it

jsJoda = require('js-joda')
    .use(require('js-joda-timezone'))

const {LocalDateTime, ZoneId, ZonedDateTime } = jsJoda;

const zone = ZoneId.of('Europe/Berlin')
const zdt = LocalDateTime.parse('2016-06-30T11:30').atZone(zone) // 2016-06-30T11:30+02:00[Europe/Berlin]
ZonedDateTime.parse('2016-06-30T11:30+02:00[Europe/Berlin]')     // 2016-06-30T11:30+02:00[Europe/Berlin]
zdt.withZoneSameInstant(ZoneId.of('America/New_York')) // 2016-06-30T05:30-04:00[America/New_York]
zdt.withZoneSameLocal(ZoneId.of('America/New_York'))   // 2016-06-30T11:30-04:00[America/New_York]

Browser

<script src="../dist/js-joda.js"></script>
<script src="../dist/js-joda-timezone.js"></script>
<script>
    // use js-joda-timezone
    JSJoda.use(JSJodaTimezone)

    // copy all js-joda classes to the global scope
    for(let key in JSJoda) { this[key] = JSJoda[key]; }

    const zone = ZoneId.of('Europe/Berlin')
    let zdt = LocalDateTime.parse('2016-06-30T11:30').atZone(zone)
    console.log(zdt.toString()) // 2016-06-30T11:30+02:00[Europe/Berlin]

    zdt = ZonedDateTime.parse('2016-06-30T11:30+02:00[Europe/Berlin]')
    console.log(zdt.toString()) // 2016-06-30T11:30+02:00[Europe/Berlin]

    zdtl = zdt.withZoneSameInstant(ZoneId.of('America/New_York'))
    console.log(zdtl.toString())  // 2016-06-30T05:30-04:00[America/New_York]

    zdti = zdt.withZoneSameLocal(ZoneId.of('America/New_York'))
    console.log(zdti.toString()) // 2016-06-30T11:30-04:00[America/New_York]
</script>

Known Issues

The package is incomplete, has pure test coverage and work is in progress.

  • ZoneDateTime methods should work correctly, except for calculations during a daylight saving transition
  • LocalDate.atStartOfDay(zone) might return wrong date if the start of day is within a daylight saving transition. (very rare case like at gaza)
  • ZoneRules only implement methods that are required by js-joda core, there is still functionality missing
  • other ZoneRules methods (like standardOffset) are not supported

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.

Keywords

date

FAQs

Package last updated on 13 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts