定制 fisharebest/ext-calendar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fisharebest/ext-calendar

Composer 安装命令:

composer require fisharebest/ext-calendar

包简介

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

README 文档

README

Build Status Coverage Status SensioLabsInsight Scrutinizer Code Quality StyleCI Code Climate

PHP calendar functions

This package provides an implementation of the Arabic (Hijri), French Republican, Gregorian, Julian, Jewish and Persian (Jalali) calendars, plus a replacement for PHP‘s ext/calendar extension. It allows you to use the following PHP functions on servers that do not have the ext/calendar extension installed (such as HHVM).

How to use it

Add the package as a dependency in your composer.json file:

require {
    "fisharebest/ext-calendar": "~2.5"
}

Now you can use the PHP functions, whether ext/calendar is installed or not. Since version 2.2, it is no longer necessary to initialise these using Shim::create().

require 'vendor/autoload.php';
print_r(cal_info(CAL_GREGORIAN)); // Works in HHVM, or if ext-calendar is not installed

Alternatively, just use the calendar classes directly.

require 'vendor/autoload.php';

// Create calendars
$calendar = new Fisharebest\ExtCalendar\ArabicCalendar;
$calendar = new Fisharebest\ExtCalendar\FrenchCalendar;
$calendar = new Fisharebest\ExtCalendar\GregorianCalendar;
$calendar = new Fisharebest\ExtCalendar\JewishCalendar;
$calendar = new Fisharebest\ExtCalendar\JulianCalendar;
$calendar = new Fisharebest\ExtCalendar\PersianCalendar;

// Date conversions
$julian_day = $calendar->ymdToJd($year, $month, $day);
list($year, $month, $day) = $calendar->jdToYmd($julian_day);

// Information about days, weeks and months
$is_leap_year   = $calendar->isLeapYear($year);
$days_in_month  = $calendar->daysInMonth($year, $month);
$months_in_year = $calendar->monthsInYear();       // Not all calendars have 12
$months_in_year = $calendar->monthsInYear($year);  // In a specific year
$days_in_week   = $calendar->daysInWeek();         // Not all calendars have 7

// Which dates are valid for this calendar?
$jd = $calendar->jdStart();
$jd = $calendar->jdEnd();

// Miscellaneous utilities
$jewish = new JewishCalendar;
$jewish->numberToHebrewNumerals(5781, false); // "תשפ״א"
$jewish->numberToHebrewNumerals(5781, true);  // "ה׳תשפ״א"

Known restrictions and limitations

When faced with invalid inputs, the shim functions trigger E_USER_WARNING instead of E_WARNING. The text of the error messages is the same.

The functions easterdate() and jdtounixtime() use PHP‘s timezone, instead of the operating system‘s timezone. These may be different.

Compatibility with different versions of PHP

The following PHP bugs are emulated, according to the version of PHP being used. Thus the package always provides the same behaviour as the native ext/calendar extension.

  • #54254 Jewish month "Adar" - fixed in PHP 5.5.

  • #67960 Constants CAL_DOW_SHORT and CAL_DOW_LONG - found and fixed by this project - fixed in PHP 5.5.21 and 5.6.5.

  • #67976 Wrong value in cal_days_in_month() for French calendar - found by this project.

Development and contributions

Due to the known restrictions above, you may need to run unit tests using TZ=UTC phpunit.

Pull requests are welcome. Please ensure you include unit-tests where applicable.

History

These functions were originally written for the webtrees project. As part of a refactoring process, they were extracted to a standalone library, given version numbers, unit tests, etc.

Future plans

  • Support alternate leap-year schemes for the French calendar (true equinox, Romme, 128-year cycle) as well as the 4-year cycle.
  • Support other calendars, such as Ethiopian, Hindu, Chinese, etc.

fisharebest/ext-calendar 适用场景与选型建议

fisharebest/ext-calendar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 504.93k 次下载、GitHub Stars 达 31, 最近一次更新时间为 2014 年 09 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「calendar」 「arabic」 「persian」 「Jalali」 「gregorian」 「french」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fisharebest/ext-calendar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fisharebest/ext-calendar 我们能提供哪些服务?
定制开发 / 二次开发

基于 fisharebest/ext-calendar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 504.93k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 36
  • 点击次数: 30
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

  • Stars: 31
  • Watchers: 3
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2014-09-10