islamic-network/prayer-times

精确且强大的PHP祈祷时间库

1.0.29 2024-03-17 08:24 UTC

README

CI Releases

祈祷时间库(PHP)

这是PrayTimes.org的Hamid Zarrabi-Zadeh最初用JavaScript编写的祈祷时间库(v2.3)的PHP版本,可在http://praytimes.org/code/v2/js/PrayTimes.js找到。它自从首次编写以来已经进行了很多改进,所以请不要将其用作“类似替代” - 方法名(以及其他一些内容)是不同的。

如何使用此库

该库是一个composer包,因此要安装它,请运行

composer require islamic-network/prayer-times

使用它相当简单

<?php
require_once("vendor/autoload.php");
use IslamicNetwork\PrayerTimes\PrayerTimes;

// Instantiate the class with your chosen method, Juristic School for Asr and if you want or own Asr factor, make the juristic school null and pass your own Asr shadow factor as the third parameter. Note that all parameters are optional.

$pt = new PrayerTimes('ISNA'); // new PrayerTimes($method, $asrJuristicMethod, $asrShadowFactor);

// Then, to get times for today.

$times = $pt->getTimesForToday($latitude, $longitude, $timezone, $elevation = null, $latitudeAdjustmentMethod = self::LATITUDE_ADJUSTMENT_METHOD_ANGLE, $midnightMode = self::MIDNIGHT_MODE_STANDARD, $format = self::TIME_FORMAT_24H);

// Or, if you want times for another day

$times = $pt->getTimes(DateTime $date, $latitude, $longitude, $elevation = null, $latitudeAdjustmentMethod = self::LATITUDE_ADJUSTMENT_METHOD_ANGLE, $midnightMode = self::MIDNIGHT_MODE_STANDARD, $format = self::TIME_FORMAT_24H);

//If you would like to offset the time for each result by a particular number of minutes, simply call the tune method before calling getTimes or getTimesForToday.

$pt->tune($imsak = 0, $fajr= 0, $sunrise = 0, $dhuhr = 0, $asr = 0, $maghrib = 0, $sunset = 0, $isha = 0, $midnight = 0);

// Finally, you can also create your own methods:
$method = new Method('My Custom Method');
$method->setFajrAngle(18);
$method->setMaghribAngleOrMins(19.5);
$method->setIshaAngleOrMins('90 min');
// And then:
$pt = new PrayerTimes(PrayerTimes::METHOD_CUSTOM);
$pt->setCustomMethod($method);
// And then the same as before:
$times = $pt->getTimesForToday($latitude, $longitude, $timezone, $elevation = null, $latitudeAdjustmentMethod = self::LATITUDE_ADJUSTMENT_METHOD_ANGLE, $midnightMode = self::MIDNIGHT_MODE_STANDARD, $format = self::TIME_FORMAT_24H);

方法

支持的方法可以在https://github.com/islamic-network/prayer-times/blob/master/src/PrayerTimes/Method.php#L10查看。

理解方法

有关方法的讨论,请参阅https://aladhan.com/calculation-methods

测试

比较此库产生的结果与原始JS版本的结果。

贡献者

Hamid Zarrabi-Zadeh,Meezaan-ud-Din Abdu Dhil-Jalali Wal-Ikram

许可证

与原始版本相同 - 许可证:GNU LGPL v3.0,这实际上意味着

Permission is granted to use this code, with or without modification, in any website or application provided that credit is given to the original work with a link back to PrayTimes.org.