@worldkit/timezone
v1.0.3
Published
Modular timezone lookup and UTC offset functions
Maintainers
Readme
⏰ @worldkit/timezone
Fast IANA timezone dataset and UTC offset lookup library for JavaScript & TypeScript.
Lookup 400+ IANA timezones by country ISO2 code and resolve UTC offsets instantly.
📚 Full Documentation: https://worldkit.in/docs/timezone
⚡ Features
- 🌍 400+ IANA Timezones: Complete mapping of IANA timezone names (e.g.
"Asia/Kolkata","America/New_York"). - ⏱️ Instant UTC Offsets: Get standard UTC offset strings (e.g.
"+05:30","-05:00"). - 🚀 Zero Latency ($O(1)$): Fast memory lookup with zero network calls.
- 📦 Micro Size: ~1.2 KB gzipped.
📦 Install
npm install @worldkit/timezone
# or
pnpm add @worldkit/timezone
# or
yarn add @worldkit/timezone💡 Usage
import { timezones, utcOffset } from "@worldkit/timezone";
// 1. Get official timezones for a Country ISO2 code
const inTimezones = timezones("IN");
console.log(inTimezones); // ["Asia/Kolkata"]
const usTimezones = timezones("US");
console.log(usTimezones);
// ["America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", ...]
// 2. Get UTC offset for an IANA timezone name
console.log(utcOffset("Asia/Kolkata")); // "+05:30"
console.log(utcOffset("America/New_York")); // "-05:00"
console.log(utcOffset("Europe/London")); // "+00:00"📖 API Reference
timezones(countryIso2: string): string[]
Returns an array of IANA timezone strings for the given country ISO2 code (e.g. "IN" -> ["Asia/Kolkata"]).
utcOffset(timezoneName: string): string
Returns the UTC offset string (e.g. "+05:30") for a specified IANA timezone name.
📐 TypeScript Support
Fully typed ESM module with complete TypeScript declarations.
🔗 Related Packages
Explore the rest of the WorldKit ecosystem:
@worldkit/core- Unified global data toolkit.@worldkit/countries- 250+ country dataset.@worldkit/react- React<TimezoneSelect />component.
📜 License
MIT © WorldKit
