# @bigbinary/neeto-time-zones 中文文档

规范地址：https://npmcn.com/package/%40bigbinary/neeto-time-zones/

版本：0\.8\.27
npm 元数据更新时间：2026-11-03T20:09:45.007Z
中文译文更新时间：2026-11-08T01:58:50.479Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40bigbinary/neeto-time-zones
原文对照：https://npmcn.com/package/%40bigbinary/neeto-time-zones/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：3.1 MB，151 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=18\.12
- 运行依赖：2 个
- peer 依赖：ramda ^0\.29\.1，react ^18 \|\| ^17\.0\.1 \|\| ^16，react-dom ^18 \|\| ^17\.0\.1 \|\| ^16，@bigbinary/neeto-cist ^1\.0\.4
- 首次发布：2023-10-12T15:49:49.135Z
- 最新版本发布：2026-11-03T20:09:44.827Z
- 近 30 天下载量：36135（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：52（近 12 个月 14 个）

## 中文简介

![npm version](https://img.shields.io/npm/v/@bigbinary/neeto-time-zones.svg) ![license](https://img.shields.io/npm/l/@bigbinary/neeto-time-zones.svg)

## 安装

```sh
npm install @bigbinary/neeto-time-zones
```

也可以使用：`pnpm add @bigbinary/neeto-time-zones`、`yarn add @bigbinary/neeto-time-zones`、`bun add @bigbinary/neeto-time-zones`

## README

# @ bigbinary/ 需要时区

![npm version](https://img.shields.io/npm/v/@bigbinary/neeto-time-zones.svg) ![license](https://img.shields.io/npm/l/@bigbinary/neeto-time-zones.svg)

与时区合作的简单而轻量级的国家预防机制一揽子计划。 这个软件包为时区提供了人类友好的时区选择器和实用功能.

## 安装

您可以使用纱线安装软件包 :

```bash
yarn add @bigbinary/neeto-time-zones
```

## 将 CSS 样式导入到主样式表

您应该添加以下内容 `main.scss` 文件 :

```css
@import "@bigbinary/neeto-time-zones/dist/style.css";
```

## 新时区选择器

[看看现场演示](https://codepen.io/Jijin-Haridas/full/wvQbeOr)

### 用法 1

```jsx
import { NeetoTimezoneSelector } from "@bigbinary/neeto-time-zones";

const ReactComponent = () => {
  const timezoneRef = useCallback(node => {
    if (!(node !== null)) return;

    new NeetoTimezoneSelector(node, {
      elementId: "custom-selector-element",
      className: "custom-selector-class",
      initialValue: "initial-timezone",
      position: "top",
      onChange: (timezone) => {
        console.log(timezone);
      },
      onHourFormatChange: (timeFormat) => {
        console.log(timeFormat);
      }
    });
  }, []);

  return (
    <div
      ref={timezoneRef}
    />
  );
};
```

### 使用量 2

```jsx
import NeetoTimezoneSelector from "@bigbinary/neeto-time-zones/react";

const ReactComponent = () => {
  return (
    <NeetoTimezoneSelector
      elementId="custom-selector-element"
      className="custom-selector-class"
      initialValue="initial-timezone"
      position="top"
      onChange={(timezone) => {
        console.log(timezone);
      }}
      onHourFormatChange={(timeFormat) => {
        console.log(timeFormat);
      }}
    />
  );
}
```

### 配置

您可以通过选项作为第二个参数来配置时区选择器组件.

1.  元素ID: NeetoTimezoneSelector 的标识。 默认 ID 是 `timezone-selector`
2.  类Name:可添加到组件中的自定义类.
3.  初始值:时区选择器的初始值.
4.  位置:选择者应打开的位置。 可用选项 : `top`, (中文(简体) ), `bottom`默认位置为 `bottom`。 。 。 .
5.  : 当时区选择器改变时调用函数.
6.  上 HourFormatChange: 当时间格式改变时调用函数.
7.  是TimeFormatSwitchBible:将此设置为假将隐藏时间格式来切换 。 默认值为真 .
8.  是TimeFormat24H:当禁用内部时间格式切换时,请使用此道具来通过时间格式选项。 这将用于更改时区选择器内的时间格式 .

### ianaTimezone 到人可读

```js
import { ianaTimezoneToHumanReadable } from "@bigbinary/neeto-time-zones";

ianaTimezoneToHumanReadable("Asia/Calcutta") // => Indian Standard Time

ianaTimezoneToHumanReadable("America/New_York") // => Eastern Standard Time

ianaTimezoneToHumanReadable("Europe/Berlin") // => Central Standard Time
```

### 转写支持

时区标签可以在用户的浏览器语言脚本(如印地语,阿拉伯语,日语)中显示. 这是 **转写** ——英语时区名称在目标脚本中拼写而来,不是被翻译.

拾取器部件自动通过 `navigator.language` 并装入相应的转写文件。 拾取器不需要配置 .

对于消费的应用软件 `ianaTimezoneToHumanReadable` 直接( 不渲染拾取器), 调用 `initTranslations()` 一旦在应用程序启动时预装转写数据 :

```js
import { initTranslations } from "@bigbinary/neeto-time-zones";

// Call once at app startup (e.g., in your entry point)
initTranslations();

// After initTranslations resolves, ianaTimezoneToHumanReadable
// returns transliterated labels based on the browser locale.
ianaTimezoneToHumanReadable("Asia/Calcutta")
// => "इंडियन स्टैंडर्ड टाइम" (when browser locale is "hi")
// => "Indian Standard Time" (when browser locale is "en" or unsupported)
```

#### 支助的当地人(35人)

活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活活

中国地产变体自动处理:

-   `zh-Hans-CN`, (中文(简体) ), `zh-Hans`, (中文(简体) ), `zh-SG`, (中文(简体) ), `zh` - 简化中文(`zh-CN`(中文(简体) )
-   `zh-Hant-TW`, (中文(简体) ), `zh-Hant`, (中文(简体) ), `zh-HK`, (中文(简体) ), `zh-MO` ——传统汉语`zh-TW`(中文(简体) )

#### 添加新区域

1.  创建 `data/translations/<locale>.json` 带有所需结构(见现有文件供参考)
2.  复制文件到 `ruby/data/translations/<locale>.json`
3.  添加一个 `case "<locale>": return () => import("../../data/translations/<locale>.json");` 输入 `js/translations/index.js`
4.  重建软件包

### 获取时区对象

```js
import { getTimezoneObject } from "@bigbinary/neeto-time-zones";

getTimezoneObject("Asia/Kolkata")
// => { utc: ["Asia/Kolkata", "Asia/Calcutta"], main: "Asia/Kolkata", label: "Indian Standard Time", ... }
```

### 是时区

```js
import { isValidTimezone } from "@bigbinary/neeto-time-zones";

isValidTimezone("Asia/Kolkata") // => true
isValidTimezone("Invalid/Zone") // => false
```

### 获取浏览时区

```js
import { getBrowserTimezone } from "@bigbinary/neeto-time-zones";

getBrowserTimezone() // => "Asia/Kolkata" (based on browser's Intl API)
```

## 发展

### 清除还原

```bash
git clone git@github.com:bigbinary/neeto-time-zones.git
cd neeto-time-zones/js
yarn install
yarn dev
```

要与主机应用程序捆绑 :

```bash
yarn build && cp dist/* ../../neeto-cal-web/node_modules/@bigbinary/neeto-time-zones/dist
```

## 出版指令

将标记为补丁、次要或主干件的PR合并到主分支后,将发布一个软件包。 补丁标签地址为错误修正, 小符号表示新特性的添加, 并主要表示断开更改, 坚持其中概述的原则 [语义版 (SemVer)](https://semver.org/)。 。 。 .

您可以在 GitHub 动作中检查并发布发布工作流程, 以获取实时更新 .

## 常见问题

### 如何安装 @bigbinary/neeto-time-zones？

在项目目录运行 npm install @bigbinary/neeto-time-zones，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：ramda（^0\.29\.1）、react（^18 \|\| ^17\.0\.1 \|\| ^16）、react-dom（^18 \|\| ^17\.0\.1 \|\| ^16）、@bigbinary/neeto-cist（^1\.0\.4）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @bigbinary/neeto-time-zones 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @bigbinary/neeto-time-zones 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @bigbinary/neeto-time-zones 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18\.12。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @bigbinary/neeto-time-zones 可以商用吗？

@bigbinary/neeto-time-zones 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @bigbinary/neeto-time-zones 的下载量有多少？

根据 npm 官方下载统计，@bigbinary/neeto-time-zones 在 2026/10/08 – 2026/11/06 这 30 天内被下载 36,135 次，日均约 1,205 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @bigbinary/neeto-time-zones 还在维护吗？

最新版本 0\.8\.27 发布于 2026/11/04（4 天前）；至今共发布 52 个版本，其中过去 12 个月发布了 14 个；首次发布于 2023/10/12。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

