@doranjs/core

中文文档
0.3.0发布于 2026/08/16MITTypeScriptESM + CJS零依赖近 30 天下载 2047

Immutable, accurate Solar Hijri (Persian/Jalali) date engine with conversion, arithmetic, parsing and formatting.

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Parsing
  4. Conversion primitives
  5. Key ideas
  6. License

@doranjs/core

Immutable, accurate Solar Hijri (Persian / Jalali) date engine.

The foundation of the Doran ecosystem. Zero runtime dependencies, tree-shakeable, and strongly typed.

Install

pnpm add @doranjs/core

Usage

import { DoranDate } from '@doranjs/core';

const today = DoranDate.now();

today.format('YYYY/MM/DD'); // "۱۴۰۵/۰۳/۱۱"
today.addDays(10).format('dddd D MMMM YYYY');
today.addMonths(1);
today.toGregorian(); // native Date

DoranDate.fromGregorian(new Date());
DoranDate.fromJalali(1405, 3, 11, { timeZone: 'Asia/Tehran' });

Parsing

import { parseJalali } from '@doranjs/core';

parseJalali('1405/03/11');
parseJalali('۱۴۰۵-۰۳-۱۱ ۰۷:۳۰');
parseJalali('11 خرداد 1405', 'D MMMM YYYY');

Conversion primitives

import { jalaliToGregorian, gregorianToJalali, isLeapJalaliYear } from '@doranjs/core';

jalaliToGregorian(1400, 1, 1); // { year: 2021, month: 3, day: 21 }
gregorianToJalali(2021, 3, 21); // { year: 1400, month: 1, day: 1 }
isLeapJalaliYear(1399); // true

Key ideas

  • Immutable — every addX / withX returns a new DoranDate.
  • Instant-based — a date is an absolute instant plus an IANA time zone, so conversions and time-zone changes are always exact.
  • Accurate — conversion uses the well-established Borkowski / jalaali algorithm, validated by an exhaustive day-by-day round-trip test suite.

See the full API reference for every method and format token.

License

MIT

版本与发布记录

@doranjs/core 共发布 10 个版本,首次发布于 2026/06/01;过去 12 个月发布了 10 个版本。

版本发布日期距今
0.3.0latest2026/08/162 个月前
0.2.02026/08/152 个月前
0.1.32026/07/183 个月前
0.1.22026/07/154 个月前
0.1.12026/07/124 个月前
0.1.02026/06/264 个月前

关于 @doranjs/core 的常见问题

@doranjs/core 是什么?

Immutable, accurate Solar Hijri (Persian/Jalali) date engine with conversion, arithmetic, parsing and formatting.

如何安装 @doranjs/core?

在项目目录运行 npm install @doranjs/core,或使用 pnpm add / yarn add / bun add。

@doranjs/core 支持 TypeScript 吗?

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

@doranjs/core 支持 ESM 还是 CommonJS?

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

@doranjs/core 可以商用吗?

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

@doranjs/core 的下载量有多少?

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

@doranjs/core 还在维护吗?

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