Code Monkey home page Code Monkey logo

windows-iana's Introduction

Build Status Coverage Status

This library exports two functions to help convert from Windows time zones to IANA time zones (based on this mapping definition and this list of IANA aliases).

Installation

Add the dependency to your project with npm install --save windows-iana or yarn add windows-iana.

Usage

The library exports:

  • findIana(): will return an array of possible IANA time zones, including all their aliases.
  • findOneIana(): will return just one string.
  • findWindows(): will return a string with a Windows time zone.
  • findAlias(): will an array of all IANA aliases, including the one passed as a parameter.
  • getAllIanaWindowsMap(): will return an map of all IANA time zones as key, and a Windows time zone as value.

findOneIana()

import { findOneIana } from "windows-iana";

const result = findOneIana("Romance Standard Time");
console.log(result); // "Europe/Paris"

You may also pass the territory code as a second parameter (have a look again at the mapping by unicode.org for more details).

import { findOneIana } from "windows-iana";

const result = findOneIana("Romance Standard Time", "ES");
console.log(result); // "Europe/Madrid"

findIana()

import { findIana } from "windows-iana";

const result = findIana("Romance Standard Time");
console.log(result); // ["Europe/Paris"]

You may also pass the territory code to findIana().

import { findIana } from "windows-iana";

const result = findIana("Romance Standard Time", "ES");
console.log(result); // ["Europe/Madrid", "Africa/Ceuta"]

findWindows()

import { findWindows } from "windows-iana";

const result = findWindows("America/New_York");
console.log(result); // Eastern Standard Time

There is no territory code for this function because all IANA names map to exactly one territory.

findAlias()

import { findAlias } from "windows-iana";

const result = findAlias("America/New_York");
console.log(result); // ["America/New_York", "US/Eastern"]

getAllIanaWindowsMap()

import { getAllIanaWindowsMap } from "windows-iana";

const result = getAllIanaWindowsMap();
console.log(result.get('America/New_York')); // Eastern Standard Time

windows-iana's People

Contributors

funkydev avatar nathanrobb avatar willyboy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.