npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nation-zone

v1.1.6

Published

From BANDENG developer team.

Downloads

558

Readme

Language / 语言: English · 中文


Nation Zone

Welcome to the Nation Zone project. This project is designed to convert time zones and currencies for different countries and regions.

TypeScript Support

This package includes full TypeScript support with type definitions. Simply install the package and TypeScript will automatically recognize the types.

Module Compatibility

This package supports both CommonJS and ES6 module imports:

CommonJS (Node.js):

const {MAP_NATIONS_CURRENCY, getNationTimeNow} = require('nation-zone')

ES6 Modules (Modern Frontend):

import {MAP_NATIONS_CURRENCY, getNationTimeNow} from 'nation-zone'

Note:

  1. This module is completely implemented based on UTC, and it does not support switching between winter time and daylight saving time.
  2. Follow the ISO8601 standard.
  3. Comprehensive country/region coverage with 118 countries and regions supported.

Features

  1. Comprehensive Country Coverage: Support for 118 countries and regions across Europe (42 countries), Americas (34 countries), Asia, Africa, and Oceania.

  2. Time Zone Matching: Match the time zone corresponding to the country/region.

  3. Currency Matching: Match the currency corresponding to the country/region, including 85 currency units.

  4. Time Zone Conversion: Converts the local time zone to the time zone of the specified country/region.

  5. Timestamp Conversion: Converts a time string to a timestamp in the time zone of the specified country/region.

  6. Time Period Splitting: Split timestamp paragraphs by day, week and month based on the time zone of the country/region.

Recent Updates

v1.1.6

  • Senegal: Added SEN (ISO 3166-1 alpha-3) with currency XOF (ISO 4217), charge unit XOF-XOF, symbol CFA, and UTC+0 timezone
  • Sri Lanka: Added LKA (ISO 3166-1 alpha-3) with currency LKR (ISO 4217), charge unit LKR-CENT, symbol Rs, and UTC+5.5 timezone

Installation

To install the necessary dependencies, run the following command:

npm install nation-zone

Usage

Basic Examples

Get country currency:

import {MAP_NATIONS_CURRENCY} from 'nation-zone'

const chinaCurrency = MAP_NATIONS_CURRENCY.get('CHN') // 'CNY'
const usaCurrency = MAP_NATIONS_CURRENCY.get('USA') // 'USD'

Get currency symbol:

import {MAP_NATIONS_CURRENCY_SYMBOL} from 'nation-zone'

const chinaSymbol = MAP_NATIONS_CURRENCY_SYMBOL.get('CHN') // '¥'
const usaSymbol = MAP_NATIONS_CURRENCY_SYMBOL.get('USA') // '$'

Get country time zone:

import {MAP_TIME_ZONES} from 'nation-zone'

const chinaTimezone = MAP_TIME_ZONES.get('CHN') // [8]
const usaTimezone = MAP_TIME_ZONES.get('USA') // [-5]

Convert timestamp to country time:

import {getNationTimeNow} from 'nation-zone'

const chinaTime = getNationTimeNow('CHN') // "2024-01-15 14:30:25.123"
const usaTime = getNationTimeNow('USA') // "2024-01-15 01:30:25.123"

Parse time string to timestamp:

import {parseNationTimestamp} from 'nation-zone'

const timestamp = parseNationTimestamp('CHN', '2024-01-15 14:30:25')
// Returns timestamp in milliseconds (UTC)

Have fun exploring global time zones and currencies!

License

This project is licensed under the MIT License.

Contact

For any questions or feedback, please contact [email protected].


Nation Zone

欢迎使用 Nation Zone。本项目用于不同国家/地区的时区与货币转换。

TypeScript 支持

本包提供完整的 TypeScript 类型定义,安装后 TypeScript 可自动识别类型。

模块兼容性

同时支持 CommonJS 与 ES Module 两种导入方式:

CommonJS(Node.js):

const {MAP_NATIONS_CURRENCY, getNationTimeNow} = require('nation-zone')

ES Module(现代前端):

import {MAP_NATIONS_CURRENCY, getNationTimeNow} from 'nation-zone'

说明

  1. 本模块完全基于 UTC 实现,不支持冬令时/夏令时切换。
  2. 时间格式遵循 ISO8601 标准。
  3. 覆盖 118 个国家/地区。

功能特性

  1. 广泛的国家/地区覆盖:支持欧洲(42 国)、美洲(34 国)、亚洲、非洲及大洋洲,共 118 个国家/地区。

  2. 时区匹配:匹配国家/地区对应的 UTC 时区。

  3. 货币匹配:匹配国家/地区对应的 ISO 4217 货币代码,含 85 种货币。

  4. 时区转换:将本地时区转换到指定国家/地区的时区。

  5. 时间戳转换:将时间字符串转换为指定国家/地区时区下的 UTC 毫秒时间戳。

  6. 时间段拆分:按国家/地区时区,以天、周、月为单位拆分时间戳区间。

最近更新

v1.1.6

  • 塞内加尔:新增 SEN(ISO 3166-1 alpha-3),货币 XOF(ISO 4217),计价单位 XOF-XOF,符号 CFA,时区 UTC+0
  • 斯里兰卡:新增 LKA(ISO 3166-1 alpha-3),货币 LKR(ISO 4217),计价单位 LKR-CENT,符号 Rs,时区 UTC+5.5

安装

npm install nation-zone

用法

基础示例

获取国家/地区货币:

import {MAP_NATIONS_CURRENCY} from 'nation-zone'

const chinaCurrency = MAP_NATIONS_CURRENCY.get('CHN') // 'CNY'
const usaCurrency = MAP_NATIONS_CURRENCY.get('USA') // 'USD'

获取货币符号:

import {MAP_NATIONS_CURRENCY_SYMBOL} from 'nation-zone'

const chinaSymbol = MAP_NATIONS_CURRENCY_SYMBOL.get('CHN') // '¥'
const usaSymbol = MAP_NATIONS_CURRENCY_SYMBOL.get('USA') // '$'

获取国家/地区时区:

import {MAP_TIME_ZONES} from 'nation-zone'

const chinaTimezone = MAP_TIME_ZONES.get('CHN') // [8]
const usaTimezone = MAP_TIME_ZONES.get('USA') // [-5]

将时间戳转换为指定国家/地区时间:

import {getNationTimeNow} from 'nation-zone'

const chinaTime = getNationTimeNow('CHN') // "2024-01-15 14:30:25.123"
const usaTime = getNationTimeNow('USA') // "2024-01-15 01:30:25.123"

将时间字符串解析为时间戳:

import {parseNationTimestamp} from 'nation-zone'

const timestamp = parseNationTimestamp('CHN', '2024-01-15 14:30:25')
// 返回 UTC 毫秒时间戳

祝使用愉快!

许可证

本项目采用 MIT License

联系方式

如有问题或建议,请联系 [email protected]