islamic-network/calendar 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

islamic-network/calendar

最新稳定版本:1.21

Composer 安装命令:

composer require islamic-network/calendar

包简介

A calendar / date conversion library from Gregorian to Hijri and vice versa.

README 文档

README

This typed PHP library is an enhancement on the existing Hijri Calculations in the Al Adhan API (https://aladhan.com). It adds new calculation methods and unit tests leaves room for additional calculation methods to be added.

It will be replacing the current calculation in the API from January 1, 2025 onwards.

Supported Methods

This library supports the following methods for calculating the Hijri Date from a Gregorian Date:

  • The existing mathematical method used on the aladhan.com API. This is the only method that accepts an adjustment parameter.
  • The Umm Al Qura astronomical calculation method. This method only works (as of this writing, as the data gets enhanced more years may be supported) from 1356 AH to 2077 AH.
  • The High Judiciary Council of Saudi Arabia calulcation method. This method is based on the Umm al-Qura calendar, but the dates for the months of Muḥarram, Ramaḍān, Shawwāl and Dhu ʾl-Ḥijja are adjusted after reported sightings of the lunar crescent announced by the Majlis al-Qadāʾ al-Aʿlā (High Judiciary Council of Saudi Arabia). Please also see https://webspace.science.uu.nl/~gent0113/islam/ummalqura_adjust.htm for more details.
  • The Diyanet astronomical calculation method. This method only works (as of this writing, as the data gets enhanced more years may be supported) from 1318 AH to 1449 AH.

Method Credits

Both the Umm Al Qura and Diyanet calendars are based on the work of Robert Harry van Gent at https://webspace.science.uu.nl/~gent0113/islam/ and inspired by the JS script written by Tariq Alomaireeni at https://github.com/talomaireeni/Umm-Al-Qura-Calendar/tree/master?tab=readme-ov-file.

Installation

composer require islamic-network/calendar

Usage

Instantiate the Appropriate class for the method you are interested in.

Umm al Qura

use IslamicNetwork\Calendar\Models\Astronomical\UmmAlQura;

// This will become the default method in the AlAdhan API in 2025
$uaq = new UmmAlQura();
/**
* @var $hijriDate \IslamicNetwork\Calendar\Types\Hijri\Date
 */
$h = $uaq->gToH('14-02-2025');

/**
* @var $g DateTime
 */
$g = $uaq->hToG('15-08-1446');

// Access the typed hijri date object.
$h->day->number;
$h->month->number;

// And the standard DateTime object for the gregorian date
$g->format('Y-m-d');

High Judiciary Council of Saudi Arabia

This will become the default method in the AlAdhan API in 2025.

use IslamicNetwork\Calendar\Models\Astronomical\HighJudiciaryCouncilOfSaudiArabia;

// This will become the default method in the AlAdhan API in 2025
$hjcosa = new \IslamicNetwork\Calendar\Models\Astronomical\HighJudiciaryCouncilOfSaudiArabia();
/**
* @var $hijriDate \IslamicNetwork\Calendar\Types\Hijri\Date
 */
$h = $hjcosa->gToH('14-02-2025');

/**
* @var $g DateTime
 */
$g = $hjcosa->hToG('15-08-1446');

// Access the typed hijri date object.
$h->day->number;
$h->month->number;

// And the standard DateTime object for the gregorian date
$g->format('Y-m-d');

Diyanet

use IslamicNetwork\Calendar\Models\Astronomical\Diyanet;

$diyanet = new Diyanet();
/**
* @var $hijriDate \IslamicNetwork\Calendar\Types\Hijri\Date
 */
$h = $diyanet->gToH('14-02-2025');

/**
* @var $g DateTime
 */
$g = $diyanet->hToG('15-08-1446');

// Access the typed hijri date object.
$h->day->number;
$h->month->number;

// And the standard DateTime object for the gregorian date
$g->format('Y-m-d');

Mathematical

This is the method used in the AlAdhan API prior to 2025.

use IslamicNetwork\Calendar\Models\Mathematical\Calculator;

// This is the method used in the AlAdhan API prior to 2025
$mathematical = new Calculator();
/**
* @var $hijriDate \IslamicNetwork\Calendar\Types\Hijri\Date
 */
$h = $mathematical->gToH('14-02-2025');
// OR 
$h = $mathematical->gToH('14-02-2025', 1); // to adjust the resulting hijri date forward by 1 day

/**
* @var $g DateTime
 */
$g = $mathematical->hToG('15-08-1446');

// Access the typed hijri date object.
$h->day->number;
$h->month->number;

// And the standard DateTime object for the gregorian date
$g->format('Y-m-d');

Run Unit Tests

vendor/bin/phpunit tests/

License

Apache 2.0

To Do

  • Astronomical Methods - Hijri to Julian calculcation
  • Jalaali Calendar

islamic-network/calendar 适用场景与选型建议

islamic-network/calendar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 639 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 639
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-12-25