1.0.8 âĒ Published 5 months ago
@abuhasanrumi/timezone-to-country v1.0.8
A tiny (~18KB) JavaScript utility to get country information from a given timezone. Most existing timezone packages are bulky â I needed something lightweight and focused for my office work. This package gives you exactly what you need, and nothing more.
ðĶ Installation
npm install @abuhasanrumi/timezone-to-country
ð Usage
import getTimezoneInfo from '@abuhasanrumi/timezone-to-country'
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
const info = getTimezoneInfo(timezone)
console.log(info)
ð§ Why I Built This
While working on an internal project at my office, I needed to map a given timezone to its corresponding country info. Every library I found was oversized for this small task â many were 70KB+ or came with unused data. So, I built this micro-library with minimal JSON and no dependencies, optimized for performance and size.
â Features
- ð Maps IANA timezones to country details
- ðŠķ Tiny footprint (~18KB)
- ðĶ Zero dependencies
- ð Pure JSON + single function
- âĄïļ Fast lookup (O(1) via object key)
ð Data Format
Each timezone entry maps to:
{
countryCode: 'XX', // ISO country code
countryName: 'Country Name',
continentName: 'Continent'
}
ð Development
git clone https://github.com/abuhasanrumi/timezone-to-country.git
cd timezone-to-country
npm install
npm run build
ðĪ Contributing
Feel free to submit issues or PRs!
- Fork the repo
- Create your feature branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -m 'Add your feature'
- Push to the branch:
git push origin feature/your-feature
- Open a pull request
ð License
MIT ÂĐ Abu Hasan Rumi
ð Related Packages
@abuhasanrumi/state-sync
: A tiny utility (~1KB) to sync state across tabs usingBroadcastChannel
andlocalStorage
.@abuhasanrumi/micro-flow
: Tiny debounce, throttle, and rate-limiting (~364B).