Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@phensley/timezone

Package Overview
Dependencies
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@phensley/timezone

Compact timezone lib based on tz database

  • 1.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
900
increased by22.45%
Maintainers
1
Weekly downloads
 
Created
Source

@phensley/timezone

@phensley/timezone min+gzip

Compact timezone library provides the full range of tzdb data. Supports all years for which rules exist, with currently-active rules extended into the future through year 2499. https://data.iana.org/time-zones/tz-link.html

Installation

NPM:

npm install --save @phensley/timezone

Yarn:

yarn add @phensley/timezone

Examples

Resolve old timezone ids that are deprecated.

import { TZ } from '@phensley/timezone';

const id = TZ.resolveId('Pacific/Samoa');
console.log(id);
Pacific/Pago_Pago

Lookup the zone info for a timezone id at a given UTC time. Timezone offsets are in milliseconds.

const ZONES = [
  'UTC',
  'Pacific/Samoa',
  'America/New_York',
  'Pacific/Pago_Pago',
  'Asia/Tokyo',
  'Europe/Paris'
];

const now = new Date(2020, 2, 18, 12, 30, 0).getTime();
for (const zoneid of ZONES) {
  const info = TZ.fromUTC(zoneid, now);
  console.log(`${zoneid.padEnd(18)} -> ${JSON.stringify(info)}`);
}
UTC                -> {"abbr":"UTC","dst":0,"offset":0,"zoneid":"Etc/UTC"}
Pacific/Samoa      -> {"abbr":"SST","dst":0,"offset":-39600000,"zoneid":"Pacific/Pago_Pago"}
America/New_York   -> {"abbr":"EDT","dst":1,"offset":-14400000,"zoneid":"America/New_York"}
Pacific/Pago_Pago  -> {"abbr":"SST","dst":0,"offset":-39600000,"zoneid":"Pacific/Pago_Pago"}
Asia/Tokyo         -> {"abbr":"JST","dst":0,"offset":32400000,"zoneid":"Asia/Tokyo"}
Europe/Paris       -> {"abbr":"CET","dst":0,"offset":3600000,"zoneid":"Europe/Paris"}

FAQs

Package last updated on 19 Mar 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc