This library exports two functions to help convert from Windows time zones to IANA time zones (based on this mapping definition).
Add the dependency to your project with npm install --save windows-iana
or yarn add windows-iana
.
The library exports findIana()
, which will return an array of possible IANA time zones, or findOneIana()
, which will return just one string.
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"
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"]