Skip to content
This repository has been archived by the owner on Jun 28, 2019. It is now read-only.

Commit

Permalink
Merged remote
Browse files Browse the repository at this point in the history
  • Loading branch information
Meezaan-ud-Din Abdu Dhil-Jalali Wal-Ikram committed Aug 9, 2017
2 parents c101257 + d41b6d1 commit 62a0c0a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 55 deletions.
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
## Prayer Times Library (PHP)

This is a PHP edition of the Prayer Times Library (v2.3) originally written in JavaScript by Hamid Zarrabi-Zadeh of PrayTimes.org and available on http://praytimes.org/code/v2/js/PrayTimes.js.
This is a PHP edition of the Prayer Times Library (v2.3) originally written in JavaScript by Hamid Zarrabi-Zadeh of PrayTimes.org and available on http://praytimes.org/code/v2/js/PrayTimes.js. It has divulged much from the original since it was first written, so please don't use it as a 'like for like' substitute - the method names, among others things, are different..

## How to Use this Library

This is not a composer package, so you need to, for the time being, manually include it in your script.
The library is a composer package, so to install it, run:

```
composer require meezaan/prayer-times
```

Using it is rather simple:

```php
<?php
require_once('/path/to/prayerTimes.php');
use Meezaan\PrayerTimes\PrayerTimes;

// Instantiate the class with your chosen method, Jursitic School for Asr and if you want or own Asr factor, make the jursitic school null and pass your own Asr shadow factor as the third parameter. Note that all parameters are optional.
// 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);

Expand All @@ -26,11 +32,27 @@ $times = $pt->getTimes(DateTime $date, $latitude, $longitude, $elevation = null,

$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');
$method->tuneZhuhr('5 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);

```

## Motivation
## Methods

The following methods are currently supported:

AlAdhan.com uses version one of the PrayerTimes Library from PrayTimes.org. It will now use this updated version.
### Understanding Methods

For a discussion on methods, see (URL coming soon)).

## Tests

Expand All @@ -45,4 +67,4 @@ Hamid Zarrabi-Zadeh, Meezaan-ud-Din Abdu Dhil-Jalali Wal-Ikram
Same as the original - License: GNU LGPL v3.0, which effectively means:
```
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.
```
```
75 changes: 28 additions & 47 deletions src/PrayerTimes/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@

class Method
{
/**
* [$name description]
* @var [type]
*/
public $name;

/**
* [$params description]
* @var array
*/
public $params = [];

/**
* [$offset description]
* @var array
*/
public $offset = [];

/**
* [__construct description]
* @param string $name [description]
*/
public function __construct($name = 'Custom')
{
$this->name = $name;
Expand All @@ -34,65 +50,30 @@ public function __construct($name = 'Custom')
];
}

/**
* [setFajrAngle description]
* @param [type] $angle [description]
*/
public function setFajrAngle($angle)
{
$this->params[PrayerTimes::FAJR] = $angle;
}

/**
* [setMaghribAngleOrMins description]
* @param [type] $angleOrMinsAfterSunset [description]
*/
public function setMaghribAngleOrMins($angleOrMinsAfterSunset)
{
$this->params[PrayerTimes::MAGHRIB] = $angleOrMinsAfterSunset;
}

/**
* [setIshaAngleOrMins description]
* @param [type] $angleOrMinsAfterMaghrib [description]
*/
public function setIshaAngleOrMins($angleOrMinsAfterMaghrib)
{
$this->params[PrayerTimes::ISHA] = $angleOrMinsAfterMaghrib;
}
/*
public function tuneFajr($mins)
{
$this->offset[PrayerTimes::FAJR] = $mins;
}
public function tuneZhuhr($mins)
{
$this->offset[PrayerTimes::ZHUHR] = $mins;
}
public function tuneAsr($mins)
{
$this->offset[PrayerTimes::ASR] = $mins;
}
public function tuneMaghrib($mins)
{
$this->offset[PrayerTimes::MAGHRIB] = $mins;
}
public function tuneIsha($mins)
{
$this->offset[PrayerTimes::ISHA] = $mins;
}
public function tuneSunset($mins)
{
$this->offset[PrayerTimes::SUNSET] = $mins;
}
public function tuneSunrise($mins)
{
$this->offset[PrayerTimes::SUNRISE] = $mins;
}
public function tuneImsak($mins)
{
$this->offset[PrayerTimes::IMSAK] = $mins;
}
public function tuneMidnight($mins)
{
$this->offset[PrayerTimes::MIDNIGHT] = $mins;
}
*/
}
19 changes: 18 additions & 1 deletion src/PrayerTimes/PrayerTimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public function __construct($method = self::METHOD_MWL, $school = self::SCHOOL_S
$this->loadSettings();
}

/**
* [setCustomMethod description]
* @param Method $method [description]
*/
public function setCustomMethod(Method $method)
{
$this->setMethod(self::METHOD_CUSTOM);
Expand All @@ -181,7 +185,8 @@ public function setCustomMethod(Method $method)
}

/**
*
* [loadSettings description]
* @return [type] [description]
*/
private function loadSettings()
{
Expand Down Expand Up @@ -849,16 +854,28 @@ public function loadMethods()
];
}

/**
* [getMethods description]
* @return [type] [description]
*/
public function getMethods()
{
return $this->methods;
}

/**
* [getMethod description]
* @return [type] [description]
*/
public function getMethod()
{
return $this->method;
}

/**
* [getMeta description]
* @return [type] [description]
*/
public function getMeta()
{
$result = [
Expand Down

0 comments on commit 62a0c0a

Please sign in to comment.