Objective-C Library for Muslim Prayer Times

Build Status

OCPrayerTimes is an Objective-C library for calculating Muslim Prayer Times. Modified version of the original source code written by Hamid Zarrabi-Zadeh and Hussain Ali from PrayTimes.org. The source code was modified by Sumardi Shukor for taking advantage of modern Objective-C language such as ARC, object literals, etc.


OCPrayerTimes 0.1.0 and higher requires Xcode 5, targeting either iOS 6.0 and above, or Mac OS 10.8 Mountain Lion (64-bit with modern Cocoa runtime) and above.

The following Cocoa frameworks must be linked into the application target for proper compilation:

  • CoreLocation.framework


CocoaPods (Recommended)

CocoaPods is the recommended way to add OCPrayerTimes to your Xcode project.

Here’s an example Podfile that installs OCPrayerTimes.


platform :osx, '10.8'
pod 'OCPrayerTimes', '~> 0.1.0'

Then run pod install.


Just add PrayTime.h and PrayTime.m to your Xcode project.


Depending on how you configure your project you may need to #import either <OCPrayerTimes/PrayTime.h> or "PrayTime.h".

Getting prayer times for a given longitude and latitude

PrayTime *prayerTime = [[PrayTime alloc] initWithJuristic:JuristicMethodShafii
NSMutableArray *prayerTimes = [prayerTime prayerTimesDate:[NSDate date]
                                            andTimezone:[prayerTime getTimeZone]];
NSLog(@"%@", prayerTimes);

Getting prayer times from current user location

- (void)viewDidLoad
    [super viewDidLoad];

    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.distanceFilter = kCLDistanceFilterNone;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
    self.locationManager.delegate = self;

    [self.locationManager startUpdatingLocation];

    prayTime = [[PrayTime alloc] initWithJuristic:JuristicMethodShafii
    [prayTime setTimeFormat:TimeFormat12Hour];

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
    CLLocation *location = [locations lastObject];

    praytime = [prayTime prayerTimesFromLocation:location
                                         forDate:[NSDate date]];


OCPrayerTimes is available under the MIT license (see LICENSE file).

PrayTimes is free software; it is released under a GNU LGPL v3.0 license that allows you to do as you wish with it as long as you don’t attempt to claim it as your own work.



Bugs and feature request are tracked on Github


The code on which this package is based, is principally developed and maintained by Sumardi Shukor.

Class References