Moshe Berman completed the 2.0 release of his port of the KosherJava Zmanim API from Java to a Cocoa API using Objective-C. You can see the work in the KosherCocoa project page. The original work on the port dates back to Moshe’s iPhone Ultimate Omer 2 (iTunes link) app. In that app, he ported the minimum amount of code needed to calculate sunset in order to roll the day of the Omer after sunset. With Moshe’s latest check-in at github, he provided a port of a good portion of the API sticking to the basic design of the KosherJava API. The complexZmanimCalendar still remains to be ported, but the majority of zmanim in common use are in the ported ZmanimCalendar. Moshe’s blog post Introducing KosherCocoa 2.0 has additional details. Additional developer notes can be seen in the KosherCocoa wiki page. This port will be a boon to iOS developers who now have a simple way to include zmanim in their iPhone and iPad apps.
Here is some sample code that outputs zmanim to the console.
Zmanim.m
#import <Foundation/Foundation.h> #import "ZmanimCalendar.h" int main (int argc, const char * argv[]){ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // Set up the location NSString *locationName = @"Lakewood, NJ"; double latitude = 40.096; //Lakewood, NJ double longitude = -74.222; //Lakewood, NJ NSTimeZone *timeZone = [NSTimeZone timeZoneForSecondsFromGMT:-18000]; // Initialize the Zmanim Calendar GeoLocation *geoLocation = [[GeoLocation alloc] initWithName:locationName andLatitude:latitude andLongitude:longitude andTimeZone:timeZone]; ZmanimCalendar *zmanimCalendar = [[ZmanimCalendar alloc] initWithLocation:geoLocation]; // Create a Formatter for the date information NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setTimeZone:timeZone]; [formatter setDateStyle:NSDateFormatterNoStyle]; [formatter setTimeStyle:NSDateFormatterMediumStyle]; NSDate *sunrise = [zmanimCalendar sunrise]; NSDate *sofZmanShmaMGA = [zmanimCalendar sofZmanShmaMogenAvraham]; NSDate *sofZmanShmaGRA = [zmanimCalendar sofZmanShmaGra]; NSDate *sunset = [zmanimCalendar sunset]; NSLog(@"Today's Zmanim for %@", [geoLocation locationName]); NSLog(@"Sunrise: %@", [formatter stringFromDate:sunrise]); NSLog(@"Sof Zman Shema MGA: %@", [formatter stringFromDate:sofZmanShmaMGA]); NSLog(@"Sof Zman Shema GRA: %@", [formatter stringFromDate:sofZmanShmaGRA]); NSLog(@"Sunset: %@", [formatter stringFromDate:sunset]); [pool drain]; return 0; }
This would output (on February 8th):
Today's Zmanim for Lakewood, NJ Sunrise: 6:58:43 AM Sof Zman Shema MGA: 8:59:04 AM Sof Zman Shema GRA: 9:35:04 AM Sunset: 5:24:09 PM