Skip to content

Instantly share code, notes, and snippets.

@sgtsquiggs
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgtsquiggs/fb8230500cb5b8897b6d to your computer and use it in GitHub Desktop.
Save sgtsquiggs/fb8230500cb5b8897b6d to your computer and use it in GitHub Desktop.

#BAPrayerTimes

BAPrayerTimes is an Objective-C library for calculating Islamic prayer times. It provides a convenient Objective-C interface to the ITL prayer times library, making it easy to correctly calculate prayer times in iOS and OS X.

##ITL The Islamic Tools and Libraries (ITL) is a widely used library for useful Islamic tools written in C. It is an open source projects maintained by the arabeyes organization. Being written in C allows it to have high precision and be very efficient. It is used in many popular Linux utilities and is the source of prayer time calculation for this library.

##Installation The simplest way to use BAPrayerTimes is with CocoaPods.

pod 'BAPrayerTimes', '~> 1.1'

##Requirements BAPrayerTimes is officially supported on iOS 6 and above as well as OS X 10.8 and above. It will most likely work on systems much earlier than those, however no testing has been done to verify this.

##Usage Using BAPrayerTimes is very simple to use. There are a few different initializers you can use to create a BAPrayerTimes object depending on how much customization you want to add. The most basic initializer is:

BAPrayerTimes *prayerTimes = [[BAPrayerTimes alloc] initWithDate:date
                                                        latitude:35.779701
                                                       longitude:-78.641747
                                                        timeZone:timezone
                                                          method:BAPrayerMethodMWL
                                                          madhab:BAPrayerMadhabShafi];

Then you can get any of the prayer times by accessing the specific property

self.prayerTimes.fajrTime

You can access the times for Fajr, Sunrise Dhuhr, Asr, Maghrib, Isha and tomorrow's Fajr. To get prayer times for a different date, simply set the date property.

prayerTimes.date = newDate;

You can also do additional customization by using some of the other available initializers to set a custom calculation method or manual adjustments of a specific prayer time.

##Calculation Methods BAPrayerTimes provides an enum with all the options that the ITL library has. It however does not automatically set a calculation method for a specific location as there does not appear to be a definitive resource for this yet. Below are a list of suggested locations to use a particular calculation method. This list is by no means definitive and we hope to receive pull requests for any adjustments to the list.

####Umm Al-Qura Saudi Arabia, UAE, Kuwait

####North America US, Canada

####Egyptian General Authority of Survey Egypt, Jordan, Syria, Lebanon

####University of Islamic Sciences, Karachi Pakistan, India

####Muslim World League UK, Germany

Contributing

It is our sincere hope that developers adopt this library and contribute back to it, providing a high level of standard for prayer time calculation. If you wish to contribute to the Objective-C interface, please create a pull request for this repo. If you would like to contribute to the C-based library that calculates the times, please open a pull request for the ITL repo. One thing we hope to add soon are unit tests to provide ease of mind that the calculated times are correct and that changes to the code have not had any adverse effects.

License

BAPrayerTimes is available under the MIT license. See the LICENSE file for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment