winzones
v1.0.0
Published
A TypeScript library for mapping between IANA and Windows time zones
Downloads
207
Maintainers
Readme
winzones
A TypeScript library for mapping between IANA and Windows time zones
Data Source
This library uses timezone mapping data from the Unicode Common Locale Data Repository (CLDR), specifically the Windows timezone mappings. The data is regularly updated to reflect the latest timezone changes and Windows zone mappings.
We update this data regularly with new CLDR releases to ensure accuracy and completeness.
Installation
npm install winzonesUsage
import { findWindowsFromIana, findIanaFromWindows } from 'winzones';
// Convert IANA timezone to Windows
const windowsZone = findWindowsFromIana('America/New_York');
console.log(windowsZone); // 'Eastern Standard Time'
// Convert Windows timezone to IANA (returns array as one Windows zone can map to multiple IANA zones)
const ianaZones = findIanaFromWindows('Eastern Standard Time');
console.log(ianaZones); // ['America/New_York', 'America/Detroit', 'America/Toronto', ...]
// Handle cases where timezone is not found
const unknownZone = findWindowsFromIana('Invalid/Timezone');
console.log(unknownZone); // undefinedAPI
findWindowsFromIana(ianaTimezone: string): string | undefined
Finds the Windows timezone equivalent for an IANA timezone identifier.
- Parameters:
ianaTimezone- IANA timezone identifier (e.g., 'America/New_York') - Returns: Windows timezone name (e.g., 'Eastern Standard Time') or
undefinedif not found
findIanaFromWindows(windowsTimezone: string): string[] | undefined
Finds the IANA timezone equivalents for a Windows timezone.
- Parameters:
windowsTimezone- Windows timezone name (e.g., 'Eastern Standard Time') - Returns: Array of IANA timezone identifiers or
undefinedif not found
Development
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build the library
npm run build
# Type check
npm run typecheck
# Regenerate timezone data from CLDR
npm run generateLicense
MIT © Execify
Author
James Birtles [email protected]
