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

timezone-locale

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timezone-locale

Convert IANA (tz database) timezone names to localized names.

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

timezone-locale

This package is on GitHub: https://github.com/nabil1337/timezone-locale

Convert IANA (tz database) timezone names to localized names. Inspired by and with data from: https://github.com/mj1856/TimeZoneNames Zero dependencies. MIT License.

Usage

const {TimezoneNames, metazones} = require('timezone-locale');

// files are required separately to avoid bloat
const germanDisplay = require('timezone-locale/data/de_DE-display.json');
const germanCldr = require('timezone-locale/data/de-cldr.json');
const englishDisplay = require('timezone-locale/data/en_US-display.json');
const englishCldr = require('timezone-locale/data/en-cldr.json');

const timezoneNames = new TimezoneNames({
    display: {
        de_DE: germanDisplay,
        en_US: englishDisplay
    },
    cldr: {
        de: germanCldr,
        en: englishCldr
    }
}, metazones);

console.log(timezoneNames.get('Europe/Berlin', 'en_US'));
// {
//     generic: 'Central European Time',
//     standard: 'Central European Standard Time',
//     daylight: 'Central European Summer Time'
// }

console.log(timezoneNames.get('Europe/Berlin', 'de_DE'));
// {
//    generic: 'Mitteleuropäische Zeit',
//    standard: 'Mitteleuropäische Normalzeit',
//    daylight: 'Mitteleuropäische Sommerzeit'
// }

Tests

Run npm run test.

Developing & regenerating data

Place a data.json (unextracted, not the .gz) from the original repo linked in the intro into the dev directory and run node ./dev/update-data.js in the project folder to regenerate the .json files under data.

Notes

  • if you want to load all locales at once, there's an example in the test file
  • this should also work in the browser, but I haven't tested that
  • if you want more features or have found bugs, feel free to contribute to this project
  • package where I got the data from is Copyright (c) 2014 Matt Johnson (to attribute according to the MIT license)

Keywords

FAQs

Package last updated on 12 Nov 2022

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