A high-performance Node.js native addon providing seamless conversion from Windows time zone IDs to IANA time zone names using ICU’s official mapping.
icu-iana-from-windows leverages the ICU C++ API (getIDForWindowsID) to deliver accurate and reliable time zone conversions. This package is ideal for applications requiring interoperability between Windows environments and systems using the IANA time zone database.
- Accurate Mapping: Reliably converts Windows time zone IDs (e.g.,
Pacific Standard Time) to their IANA equivalents (e.g.,America/Los_Angeles) using ICU’s official mapping. - Straightforward API: Minimal and intuitive interface for easy integration into Node.js projects.
- Fills a Standards Gap: Leverages the ICU C++ API to bridge the gap between Windows and IANA time zones, addressing the lack of native support in ECMA-402 for Windows IDs.
- High Performance: Native addon implementation ensures fast and efficient conversions.
- Node.js v18 or higher
- ICU v74 or higher
This package requires ICU (International Components for Unicode) development libraries to be installed on your system before building or installing the native addon. You can install ICU using the following methods depending on your platform:
sudo apt-get update
sudo apt-get install libicu-devbrew install icu4cWe recommend using vcpkg to manage native dependencies on Windows:
vcpkg install icuMake sure to integrate vcpkg with your development environment as described in the vcpkg integration documentation.
Note: Ensure that the ICU development libraries are discoverable by your compiler and Node.js build tools (
node-gyp/cmake-js). You may need to set environment variables such asICU_ROOTor update yourPATHaccordingly.
npm install icu-iana-from-windowsconst { convertWindowsToIana } = require("icu-iana-from-windows");
const iana = convertWindowsToIana("Pacific Standard Time");
console.log(iana); // 'America/Los_Angeles'- windowsTimeZone: The Windows time zone identifier to convert.
- territory (optional): Regional code to refine the mapping (e.g.,
USforAmerica/Los_Angeles,CAforAmerica/Vancouver). - Returns: The corresponding IANA time zone name.
- Throws: An error if the conversion cannot be performed.