@bbc/psammead-calendars

中文文档
2.0.27发布于 2021/05/27Apache-2.0ESM + CJS近 30 天下载 4116

This package provides logic for formatting alternative (non-Gregorian) calendars

原始使用文档
文档目录9 节
  1. Installation
  2. Calendars
  3. Jalaali
  4. Usage
  5. Follow this template and replace CALENDAR_NAME:
  6. Jalaali Usage
  7. Contributing
  8. Code of Conduct
  9. License

psammead-calendars - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

This package provides a utility to format calendar dates provided in a Moment object to other non-gregorian calendars. For now Jalaali is the only calendar which is being converted, more may be added in the future.

Installation

npm install @bbc/psammead-calendars --save

Calendars

Jalaali

Converts a Gregorian calendar date represented by a moment object into its Jalaali calendar equivalent and outputs it as a string to be used by other components. This helper relies on jalaali-js which contains the logic to carry out the conversions from Gregorian to Jalaali. Documentation of this dependency can be found here.

This helper currently only supports Pashto and Persian/Farsi Jalaali calendar month names and Eastern Arabic numerals (translated using psammead-locales).

Usage

Follow this template and replace CALENDAR_NAME:

import { CALENDAR_NAME } from "@bbc/psammead-calendars"

Jalaali Usage

import { jalaali } from "@bbc/psammead-calendars"

const nowMoment = moment().locale('fa');
const formattedDate = jalaali.formatDate(nowMoment);

The Jalaali formatter contains a function called formatDate(). This function takes a moment object as its argument, which needs to have ps or fa set as its locale. The function then uses the moment with its logic to return a string in a day, year, month format using Eastern Arabic numerals e.g. ۱۱ دی ۱۳۹۷.

If an unsupported moment or locale set on the moment is passed in, then the output will return null.

Contributing

Psammead is completely open source. We are grateful for any contributions, whether they be new components, bug fixes or general improvements. Please see our primary contributing guide which can be found at the root of the Psammead repository.

Code of Conduct

We welcome feedback and help on this work. By participating in this project, you agree to abide by the code of conduct. Please take a moment to read it.

License

Psammead is Apache 2.0 licensed.

版本与发布记录

@bbc/psammead-calendars 共发布 29 个版本,首次发布于 2019/10/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.27latest2021/05/275 年前
2.0.262021/03/105 年前
2.0.252021/03/025 年前
2.0.242021/02/225 年前
2.0.232021/02/045 年前
2.0.222021/02/045 年前

关于 @bbc/psammead-calendars 的常见问题

@bbc/psammead-calendars 是什么?

This package provides logic for formatting alternative (non-Gregorian) calendars

如何安装 @bbc/psammead-calendars?

在项目目录运行 npm install @bbc/psammead-calendars,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:moment(2.24.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bbc/psammead-calendars 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bbc__psammead-calendars 是否存在。

@bbc/psammead-calendars 支持 ESM 还是 CommonJS?

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

@bbc/psammead-calendars 可以商用吗?

@bbc/psammead-calendars 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@bbc/psammead-calendars 的下载量有多少?

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

@bbc/psammead-calendars 还在维护吗?

最新版本 2.0.27 发布于 2021/05/27(5 年前);至今共发布 29 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/10/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。