Skip to content

Commit

Permalink
Merge pull request batoulapps#32 from batoulapps/turkey-method
Browse files Browse the repository at this point in the history
Added Turkey method. Added more documentation and improved README
  • Loading branch information
z3bi authored Apr 23, 2020
2 parents 49f8ff1 + 0a2a710 commit 3723ee7
Show file tree
Hide file tree
Showing 21 changed files with 570 additions and 92 deletions.
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
language: swift

osx_image:
- xcode10
- xcode10.1
- xcode10.2
- xcode10.3
- xcode11
- xcode11.1
- xcode11.2
- xcode11.3

env:
- SWIFT_VERSION=4.0
- SWIFT_VERSION=4.1
- SWIFT_VERSION=4.2
- SWIFT_VERSION=5.0
- SWIFT_VERSION=5.1
- SWIFT_VERSION=5.2

cache: bundler

Expand All @@ -17,8 +26,26 @@ before_install:

matrix:
exclude:
- osx_image: xcode10
env: SWIFT_VERSION=5.0
- osx_image: xcode10
env: SWIFT_VERSION=5.1
- osx_image: xcode10
env: SWIFT_VERSION=5.2
- osx_image: xcode10.1
env: SWIFT_VERSION=5.0
- osx_image: xcode10.1
env: SWIFT_VERSION=5.1
- osx_image: xcode10.1
env: SWIFT_VERSION=5.2
- osx_image: xcode10.2
env: SWIFT_VERSION=5.1
- osx_image: xcode10.2
env: SWIFT_VERSION=5.2
- osx_image: xcode10.3
env: SWIFT_VERSION=5.1
- osx_image: xcode10.3
env: SWIFT_VERSION=5.2

script:
- xcodebuild clean build -scheme 'Adhan-watchOS' -project Adhan.xcodeproj CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO SWIFT_VERSION=$SWIFT_VERSION | xcpretty
Expand Down
22 changes: 9 additions & 13 deletions Adhan.podspec
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
Pod::Spec.new do |s|
s.name = "Adhan"
s.version = "1.1.0"
s.summary = "High precision prayer time library."
s.name = 'Adhan'
s.version = '1.2.0'
s.summary = 'High precision Islamic prayer time library.'

s.description = <<-DESC
Adhan is a high precision prayer time
library with all astronomical equations
from cited authoritative sources. Adhan
is well tested and available in multiple
languages. For iOS and OS X apps Adhan
is available in Swift and with an Objective-C
compatible Swift interface.
Calculate Islamic prayer times for any location
using high precision astronomical equations from
cited authoritative sources. Written in Swift
and also compatible with Objective-C.
DESC

s.homepage = "https://github.com/batoulapps/adhan-swift"
s.license = 'MIT'
s.author = { 'Batoul Apps' => 'support@batoulapps.com' }
s.author = { 'Ameir Al-Zoubi' => 'ameir@ameir.com' }
s.source = { :git => "https://github.com/batoulapps/adhan-swift.git", :tag => s.version.to_s }

s.social_media_url = 'https://twitter.com/batoulapps'

s.swift_version = "4.2"
s.swift_versions = ['4.0', '4.2', '5.0']
s.swift_versions = ['4.0', '4.1', '4.2', '5.0', '5.1', '5.2']

s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.9'
Expand Down
18 changes: 9 additions & 9 deletions Adhan.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
children = (
8B74F4521EF55367006A51EE /* README.md */,
84F8E1211C7AB542004C48D7 /* Sources */,
84F8E12D1C7AB542004C48D7 /* AdhanTests */,
84F8E12D1C7AB542004C48D7 /* Tests */,
84F8E1201C7AB542004C48D7 /* Products */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -313,7 +313,7 @@
path = Sources;
sourceTree = "<group>";
};
84F8E12D1C7AB542004C48D7 /* AdhanTests */ = {
84F8E12D1C7AB542004C48D7 /* Tests */ = {
isa = PBXGroup;
children = (
84BCD1AD1CB09A5900614D12 /* Times */,
Expand All @@ -326,7 +326,7 @@
8480CCD81CD2DE0F00BD380B /* ObjcTests.m */,
84F8E1301C7AB542004C48D7 /* Info.plist */,
);
path = AdhanTests;
path = Tests;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -938,7 +938,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = AdhanTests/Info.plist;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.batoulapps.Adhan.Adhan-iOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -953,7 +953,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = AdhanTests/Info.plist;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.batoulapps.Adhan.Adhan-iOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -1131,7 +1131,7 @@
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = AdhanTests/Info.plist;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.batoulapps.Adhan.Adhan-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1152,7 +1152,7 @@
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = AdhanTests/Info.plist;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.batoulapps.Adhan.Adhan-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1173,7 +1173,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = AdhanTests/Info.plist;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_BUNDLE_IDENTIFIER = "com.batoulapps.Adhan.Adhan-macOSTests";
Expand All @@ -1193,7 +1193,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = AdhanTests/Info.plist;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_BUNDLE_IDENTIFIER = "com.batoulapps.Adhan.Adhan-macOSTests";
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ DEPENDENCIES
fastlane

BUNDLED WITH
1.16.6
2.1.4
65 changes: 65 additions & 0 deletions METHODS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Calculation Parameters Guide

## Calculation parameters

To calculate Prayer Times, a CalculatonParameters struct is required.
Instead of manually initializing this struct it is recommended to use one of the pre-populated
instances by calling the `params` var on the `CalculationMethod` enum. You can then further
customize the calculation parameters if needed.

```swift
var params = CalculationMethod.moonsightingCommittee.params
params.madhab = .hanafi
params.adjustments.fajr = 2
```

| Parameter | Description |
| --------- | ----------- |
| method | Which preset from the CalculationMethod enum was used. Default value is `other`. |
| fajrAngle | Angle of the sun below the horizon used to calculate Fajr. |
| maghribAngle | Angle of the sun below the horizon used to calculate Maghrib, used for some Calculation Methods. |
| ishaAngle | Angle of the sun below the horizon used to calculate Isha. |
| ishaInterval | Minutes after Maghrib (if set, the time for Isha will be Maghrib plus ishaInterval). |
| madhab | Which setting from the Madhab enum to use for calculating Asr. |
| highLatitudeRule | Which setting from the HighLatitudeRule enum to use for calculating the minimum time for Fajr and the maximum time for Isha. |
| adjustments | PrayerAdjustments struct with custom prayer time adjustments in minutes for each prayer time. |

## CalculationMethod

Preset calculation parameters for different regions.

| Value | Description |
| ----- | ----------- |
| muslimWorldLeague | Muslim World League. Standard Fajr time with an angle of 18°. Earlier Isha time with an angle of 17°. |
| egyptian | Egyptian General Authority of Survey. Early Fajr time using an angle 19.5° and a slightly earlier Isha time using an angle of 17.5°. |
| karachi | University of Islamic Sciences, Karachi. A generally applicable method that uses standard Fajr and Isha angles of 18°. |
| ummAlQura | Umm al-Qura University, Makkah. Uses a fixed interval of 90 minutes from maghrib to calculate Isha. And a slightly earlier Fajr time with an angle of 18.5°. *Note: you should add a +30 minute custom adjustment for Isha during Ramadan.* |
| dubai | Used in the UAE. Slightly earlier Fajr time and slightly later Isha time with angles of 18.2° for Fajr and Isha in addition to 3 minute offsets for sunrise, Dhuhr, Asr, and Maghrib. |
| qatar | Same Isha interval as `ummAlQura` but with the standard Fajr time using an angle of 18°. |
| kuwait | Standard Fajr time with an angle of 18°. Slightly earlier Isha time with an angle of 17.5°. |
| moonsightingCommittee | Method developed by Khalid Shaukat, founder of Moonsighting Committee Worldwide. Uses standard 18° angles for Fajr and Isha in addition to seasonal adjustment values. This method automatically applies the 1/7 approximation rule for locations above 55° latitude. Recommended for North America and the UK. |
| singapore | Used in Singapore, Malaysia, and Indonesia. Early Fajr time with an angle of 20° and standard Isha time with an angle of 18°. |
| turkey | An approximation of the Diyanet method used in Turkey. This approximation is less accurate outside the region of Turkey. |
| tehran | Institute of Geophysics, University of Tehran. Early Isha time with an angle of 14°. Slightly later Fajr time with an angle of 17.7°. Calculates Maghrib based on the sun reaching an angle of 4.5° below the horizon. |
| northAmerica | Also known as the ISNA method. Can be used for North America, but the moonsightingCommittee method is preferable. Gives later Fajr times and early Isha times with angles of 15°. |
| other | Defaults to angles of 0°, should generally be used for making a custom method and setting your own values. |

## Madhab

Rule for calculating the time for Asr.

| Value | Description |
| ----- | ----------- |
| shafi | Earlier Asr time (use for Shafi, Maliki, Hanbali, and Jafari). |
| hanafi | Later Asr time. |

## HighLatitudeRule

Rule for approximating Fajr and Isha at high latitudes.

| Value | Description |
| ----- | ----------- |
| middleOfTheNight | Fajr won't be earlier than the midpoint of the night and isha won't be later than the midpoint of the night. This is the default value to prevent fajr and isha crossing boundaries. |
| seventhOfTheNight | Fajr is at the end of the first seventh of the night and isha is at the beginning of the last seventh of the night. This is recommended to use for locations above 55° latitude to prevent prayer times that would be difficult to perform. |
| twilightAngle | The night is divided into portions of roughly 1/3. The exact value is derived by dividing the fajr/isha angles by 60. This can be used to prevent difficult fajr and isha times at locations below 55° latitude. |

65 changes: 8 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ Implementations of Adhan in other languages can be found in the parent repo [Adh

### CocoaPods

Adhan supports [CocoaPods](https://cocoapods.org/). Simply add the following line to your [Podfile](https://guides.cocoapods.org/syntax/podfile.html):
For [CocoaPods](https://cocoapods.org/) add the following to your [Podfile](https://guides.cocoapods.org/syntax/podfile.html):

```ruby
pod 'Adhan'
```

### Carthage

Adhan supports [Carthage](https://github.com/Carthage/Carthage). Simply add the following line to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile):
For [Carthage](https://github.com/Carthage/Carthage) add the following to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile):

```ruby
github "batoulapps/adhan-swift" "master"
```

### Swift Package Manager

Adhan supports [SPM](https://swift.org/package-manager/). Simply add the following line to your dependencies value of your `Package.swift` file:
For [SPM](https://swift.org/package-manager/) add the following to your `Package.swift` file:

```swift
// swift-tools-version:4.2
Expand All @@ -39,7 +39,7 @@ dependencies: [
]
```

### Manual
### Manually

You can also manually add Adhan.

Expand Down Expand Up @@ -80,61 +80,12 @@ let cal = Calendar(identifier: Calendar.Identifier.gregorian)
let date = cal.dateComponents([.year, .month, .day], from: Date())
```

#### Calculation parameters
### Calculation parameters & Calculation Methods

The rest of the needed information is contained within the `CalculationParameters` struct.
Instead of manually initializing this struct it is recommended to use one of the pre-populated
instances by calling the `params` var on the `CalculationMethod` enum. You can then further
customize the calculation parameters if needed.

```swift
var params = CalculationMethod.moonsightingCommittee.params
params.madhab = .hanafi
params.adjustments.fajr = 2
```
[Calculation Parameters & Methods Guide](METHODS.md)

| Parameter | Description |
| --------- | ----------- |
| method | Member of CalculationMethod enum |
| fajrAngle | Angle of the sun used to calculate Fajr |
| maghribAngle | Angle of the sun used to calculate Maghrib, used for some Calculation Methods |
| ishaAngle | Angle of the sun used to calculate Isha |
| ishaInterval | Minutes after Maghrib (if set, the time for Isha will be Maghrib plus ishaInterval) |
| madhab | Member of the Madhab enum, used to calculate Asr |
| highLatitudeRule | Member of the HighLatitudeRule enum, used to set a minimum time for Fajr and a max time for Isha |
| adjustments | PrayerAdjustments struct with custom prayer time adjustments in minutes for each prayer time |

**CalculationMethod**

| Value | Description |
| ----- | ----------- |
| muslimWorldLeague | Muslim World League. Fajr angle: 18, Isha angle: 17 |
| egyptian | Egyptian General Authority of Survey. Fajr angle: 19.5, Isha angle: 17.5 |
| karachi | University of Islamic Sciences, Karachi. Fajr angle: 18, Isha angle: 18 |
| ummAlQura | Umm al-Qura University, Makkah. Fajr angle: 18.5, Isha interval: 90. *Note: you should add a +30 minute custom adjustment for Isha during Ramadan.* |
| dubai | Method used in UAE. Fajr angle: 18.2, Isha angle: 18.2. |
| qatar | Modified version of Umm al-Qura used in Qatar. Fajr angle: 18, Isha interval: 90. |
| kuwait | Method used by the country of Kuwait. Fajr angle: 18, Isha angle: 17.5 |
| moonsightingCommittee | Moonsighting Committee. Fajr angle: 18, Isha angle: 18. Also uses seasonal adjustment values. |
| singapore | Method used by Singapore. Fajr angle: 20, Isha angle: 18. |
| tehran | Institute of Geophysics, University of Tehran. Fajr angle: 17.7, Maghrib angle: 4.5, Isha angle: 14. |
| northAmerica | Referred to as the ISNA method. This method is included for completeness but is not recommended. Fajr angle: 15, Isha angle: 15 |
| other | Fajr angle: 0, Isha angle: 0. This is the default value for `method` when initializing a `CalculationParameters` struct. |

**Madhab**

| Value | Description |
| ----- | ----------- |
| shafi | Earlier Asr time (use for Shafi, Maliki, Hanbali, and Jafari) |
| hanafi | Later Asr time |

**HighLatitudeRule**

| Value | Description |
| ----- | ----------- |
| middleOfTheNight | Fajr will never be earlier than the middle of the night and Isha will never be later than the middle of the night |
| seventhOfTheNight | Fajr will never be earlier than the beginning of the last seventh of the night and Isha will never be later than the end of the first seventh of the night |
| twilightAngle | Similar to SeventhOfTheNight, but instead of 1/7, the fraction of the night used is fajrAngle/60 and ishaAngle/60 |


### Prayer Times
Expand Down Expand Up @@ -188,7 +139,7 @@ let next = prayerTimes.nextPrayer()
let countdown = prayerTimes.time(for: next)
```

### Sunnah Times
## Sunnah Times

The Adhan library can also calulate Sunnah times. Given an instance of `PrayerTimes`, you can get a `SunnahTimes` struct with the times for Qiyam.

Expand All @@ -199,7 +150,7 @@ if let sunnahTimes = SunnahTimes(from: todayPrayers) {
}
```

### Qibla Direction
## Qibla Direction

Get the direction, in degrees from North, of the Qibla from a given set of coordinates.

Expand Down
Loading

0 comments on commit 3723ee7

Please sign in to comment.