eram/daynum
Composer 安装命令:
composer require eram/daynum
包简介
Immutable, zero-runtime-dependency multi-calendar library for PHP 8.1+. Gregorian, Jalali (Shamsi), and Hijri, differentially tested against ICU.
关键字:
README 文档
README
Immutable, zero-runtime-dependency, multi-calendar PHP library.
Daynum is a clean, single-package replacement for the 3–4 libraries PHP developers currently glue together to get Gregorian + Jalali (Shamsi) + Hijri support. It targets PHP 8.1+, requires no ext-intl at runtime, pulls no transitive dependencies, and is differentially tested against ICU on ~220,000 dates per calendar per CI build.
v1 ships Gregorian, Jalali, and Hijri (Saudi Umm al-Qura + tabular civil), with English, Persian, and Arabic locales.
What Daynum is (and isn't)
Daynum IS: multi-calendar date conversion + formatting, immutable arithmetic, locale-aware formatting with PHP date() tokens, a zero-dependency ICU-tested replacement for morilog/jalali.
Daynum is NOT: a timezone library (use toDateTimeImmutable() for DST math), a relative-date parser ("next Monday"), a Carbon replacement (Carbon covers Gregorian + timezones; Daynum covers multi-calendar + correctness), or a framework bridge.
Naming caveat:
Instantis civil, not UTC. Unlikejava.time.Instant, Daynum'sInstantis a calendar-neutral civil datetime:(JDN, time-of-day, timezone label). Two instants with the same JDN and time but different tzLabels represent different physical moments. See docs/en/concepts.md.
| Feature | Daynum | Carbon | morilog/jalali | ext-intl |
|---|---|---|---|---|
| Jalali | Birashk 33-year | No | Birashk (same) | Borkowski |
| Hijri UAQ | Bundled table | No | No | Runtime ICU |
| Hijri Civil | Yes | No | No | Yes |
| Runtime deps | Zero | symfony/* | nesbot/carbon | ext-intl |
| Immutable | Yes | Optional | No | N/A |
| Testing | ICU differential | Unit tests | Unit tests | IS the oracle |
Install
composer require eram/daynum:^1.0@beta
Quick start
use Eram\Daynum\Instant; use Eram\Daynum\Calendar\Jalali\JalaliView; // Construction — one calendar to pick from, three calendars to read back $d = Instant::fromGregorian(2026, 4, 8, 14, 30, 0, 'Asia/Tehran'); $d->gregorian()->format('Y-m-d'); // "2026-04-08" $d->jalali()->format('Y/m/d'); // "1405/01/19" $d->hijri()->format('j F Y'); // "21 Shawwal 1447" // Persian locale + Persian digits $d->jalali()->withLocale('fa')->withDigits('persian')->format('l j F Y'); // "چهارشنبه ۱۹ فروردین ۱۴۰۵" // Immutable arithmetic — returns Instant, re-enter a view to format $next = $d->jalali()->addMonths(1); // Instant $next->jalali()->format('Y/m/d'); // "1405/02/19" // Strict parsing — digits in any script are normalized JalaliView::parseExact('۱۴۰۵/۰۱/۱۹', 'Y/m/d'); // Instant JalaliView::tryParseExact('nope', 'Y/m/d'); // null // JSON round-trip contract json_encode($d); // {"jdn":2461139,"secondsOfDay":52200,"tzLabel":"Asia/Tehran"} Instant::fromArray(json_decode(json_encode($d), true))->equals($d); // true // Escape hatch to native PHP for real timezone math $d->toDateTimeImmutable();
Documentation
Learn
- Getting Started — install, first example, 5-minute tour
- Concepts — civil vs. UTC,
Instantvs. view, JDN, immutability - Cookbook — 10+ task-indexed recipes
- FAQ — surprising-but-intentional design decisions
Calendars
Reference
- API Reference — every type and method
- Formatting · Parsing · Arithmetic
- Localization · Timezones · Exceptions · Serialization
Migration & attribution
Contributing
Bug reports, docs fixes, new locales, and new calendar systems are welcome. See CONTRIBUTING.md for testing, fixture regeneration, and the "how to add a new calendar" checklist.
Links
- CHANGELOG.md — release notes
- LICENSE — MIT
- Issue tracker
License
MIT. See LICENSE.
eram/daynum 适用场景与选型建议
eram/daynum 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「date」 「calendar」 「arabic」 「immutable」 「persian」 「Jalali」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 eram/daynum 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eram/daynum 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 eram/daynum 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Tools to convert between .NET and PHP date formats
A modern PHP library for generating iCalendar v2.0 events
A powerful event calendar Tool for Laravel's Nova 5.
Date component is a set of methods to help with the manipulation of dates.
Convert numbers to Arabic words
Check for holidays - localeaware
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 46
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-12