ashikahmad / PrayerTimes-Swift

Islamic Prayer (salah) Time calculation written in swift.
61 stars 21 forks source link
calculations islam islamic-prayer-times prayer-times swift

PrayerTime-Swift

Islamic Prayer (salah) Time calculation written in swift. This prayer time calculation code is mostly converted from Objective C version of similar class from praytimes.org.

What it Does

It calculates prayer times for any date(s) based on:

For more information about these calculation methods and how it is obtained, check out fine document at prayertimes.org's wiki page

How to Use

Just import AKPrayerTime.swift in your project, and:

// Create PrayerKit instance with your latitude/longitude
var prayerKit:AKPrayerTime = AKPrayerTime(lat: 23.810332, lng: 90.4125181)
// Optionally, set your preferred calculation method.
// Default is Muslim World Legue (MWL) method
prayerKit.calculationMethod = .Karachi
// Optionally, set your preferred Asr method.
// Default is Safi'i
prayerKit.asrJuristic = .Hanafi
// Optionally, set your output format.
// You can obviously format it later also
prayerKit.outputFormat = .Time12
// ... and finally, get your times
var times = prayerKit.getPrayerTimes()

// Then, you can use it as
times[.Fajr]    // 04:07 am
times[.Sunrise] // 05:27 am
// ...and follow included example and public methods in source for more possibilities!

Basic configurations

Property Options
calculationMethod .MWL ➠ Muslim World League
.ISNA ➠ Islamic Society of North America
.Egypt ➠ Egyptian General Authority of Survey
.Makkah ➠ Umm al-Qura University, Makkah
.Karachi ➠ University of Islamic Science, Karachi
.Tehran ➠ Institute of Geophysics, University of Tehran
.Jafari ➠ Shia Ithna Ashari, Leva Research Institute, Qum
.Custom ➠ Autometically set when parameters are changed manually
asrJuristic .Shafii ➠ As followed by Shafi'i, Maliki, Ja'fari, and Hanbali school
.Hanafi ➠ As followed by Hanafi school

More details will be added soon. Contribution in both source and documentation is most welcome!